日期:2014-05-19  浏览次数:20962 次

求sql 汇总语句
table
id     jzl
1         2
2         5
3         8  
4         1
5         4  
6         6  

得到结果如下a列一共多少条数据,b列为jzl总和
a         b
6         16


请问这个语句怎样写


------解决方案--------------------
select count(*) as a,sum(jzl) as b from table
------解决方案--------------------
select count(*) as a,b=sum(jzl) from tablename group by id
------解决方案--------------------
select a=(select count(*) from tbName),
b=(select sum(jzl) from tbName)

------解决方案--------------------
select count(id) as a,sum(jzl) as b from a