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

求一查询语句,多谢

2012-04-12 
求一查询语句,谢谢。表a,有字段email、num,现在要求:查到供货量(num)超过5000的所有人(email)的供货总量?请

求一查询语句,谢谢。
表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

热点排行