当前位置: 代码迷 >> Sql Server >> 提问一个sql语句,帮小弟我看看
  详细解决方案

提问一个sql语句,帮小弟我看看

热度:76   发布时间:2016-04-27 20:35:39.0
提问一个sql语句,帮我看看!
select   uid,sum(shu1)   as   shu1he,sum(shu2)   as   shu2he,shu1+shu2   as   zonghe
from   shuzi
group   by   uid

中,如果要将zonghe小于1000的不显示出来,应该怎么加呢?

------解决方案--------------------
select uid,sum(shu1) as shu1he,sum(shu2) as shu2he,sum(shu1+shu2) as zonghe
from shuzi
group by uid
group by uid having sum(shu1+shu2)> =1000
------解决方案--------------------
select uid,
sum(shu1) as shu1he,
sum(shu2) as shu2he,
sum(shu1+shu2) as zonghe
from shuzi
group by uid
having sum(shu1+shu2)> =1000
------解决方案--------------------
select * from (select uid,sum(shu1) as shu1he,sum(shu2) as shu2he,shu1+shu2 as zonghe
from shuzi
group by uid) as a where a.zonghe> =1000
  相关解决方案