首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

关于ASP SQL语句的有关问题

2012-06-07 
关于ASP SQL语句的问题SQL codeselect a.saleuserid as userid,sum(a.totalpoint) as totalpoints from or

关于ASP SQL语句的问题

SQL code
select a.saleuserid as userid,sum(a.totalpoint) as totalpoints from orders a,userinfo b,CommerceAddress c where a.saleuserid=b.userid and b.uclass=1 and a.oclass=6 and a.saleuserid=c.CommerceUserID and sum(a.totalpoint)>1000000 and orderdate<='2012-05-01 23:59:59' group by a.saleuserid order by totalpoints desc  



我想让totalpoints 大于100000的数据显示出来,如何写,谢谢!

[解决办法]
select a.saleuserid as userid,sum(a.totalpoint) as totalpoints from orders a,userinfo b,CommerceAddress c where a.saleuserid=b.userid and b.uclass=1 and a.oclass=6 and a.saleuserid=c.CommerceUserID and sum(a.totalpoint)>1000000 and orderdate<='2012-05-01 23:59:59' 
group by a.saleuserid 
having sum(a.totalpoint) > 100000
order by totalpoints desc

[解决办法]
sql逻辑查运行的各个运行阶段表明
group by 在 where之后运行

where语句中不能使用聚合计算筛选

如果要对聚合结果进行筛选,应该在having子句中

热点排行