求一查询语句,谢谢。
表a,有字段email、num,现在要求:
查到供货量(num)超过5000的所有人(email)的供货总量?
请问一下,能否用一条sql语句就返回结果??
不知道大家明白我的意思没有?
------解决方案--------------------select email,sum(num) from 表A group by email having sum(num)! <5000
------解决方案--------------------select 供货总量=(select sum(num) from a where email=c.email) from a c where c.num > 5000
------解决方案--------------------select email、sum(num) 供货总量
from 表a
group by email
having sum(num) > 5000
------解决方案--------------------select emial,sum(num) from a group by email having num> 5000
------解决方案--------------------select email, sum(num) num into #1 from t group by email having sum(num)> 5000
select sum(num) from #1