having 在多条件查询中,帮帮忙
答案:6 悬赏:80
解决时间 2021-02-11 06:44
- 提问者网友:傀儡离开
- 2021-02-10 17:50
having 在多条件查询中,帮帮忙
最佳答案
- 二级知识专家网友:山鬼偶尔也合群
- 2021-02-10 18:50
你的上sql拼错了:
if B<>0 then sql=sql &" and group by yw_hao having sum(B)>="&B&""
去掉【and】
if B<>0 then sql=sql &" group by yw_hao having sum(B)>="&B&""
---
以上,希望对你有所帮助。
if B<>0 then sql=sql &" and group by yw_hao having sum(B)>="&B&""
去掉【and】
if B<>0 then sql=sql &" group by yw_hao having sum(B)>="&B&""
---
以上,希望对你有所帮助。
全部回答
- 1楼网友:留下所有热言
- 2021-02-10 23:52
having 放在 group by 后面
- 2楼网友:余生继续浪
- 2021-02-10 22:35
先分组,再having
having是对分组之后的结果集指定条件
- 3楼网友:强势废物
- 2021-02-10 21:18
Set rs=server.createobject("adodb.recordset")
A=Request.form("A")
B=Request.form("B")
C=Request.form("C")
sql="Select A,sum(B), C from table where 1=1"
if A<>"" then sql=sql &"and A like '%"&A&"%' group by A"
if B<>0 then sql=sql &"and group by A having(B)>="&B&""
if C<>"" then sql=sql &"and C='"&C&"' group by A"
rs.open sql,conn,1,1
- 4楼网友:偏爱自由
- 2021-02-10 21:05
" and group by ..." 这里语法都不正确了 ,多了 and
rs.open sql,conn,1,1 句之前看一下sql句的结果先。再把这个结果放到分析器里去运行,你就知道出错在哪 里了。
- 5楼网友:留下所有热言
- 2021-02-10 19:35
SQL语句问题多多条件都合格SQL就成什么了。。。。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯