一个 求总合的查询语句
id num class
1 11 1
2 13 1
3 12 2
4 15 2
5 20 3
6 50 3
如何 得到
num class
24 1
27 2
70 3
这样的 数据呢?
------解决方案--------------------select sum(num) num,class from 表 group by class
------解决方案--------------------SELECT class,SUM([num]) [num]
FROM [TABLENAME]
GROUP BY class
------解决方案--------------------select sum(num) as num,class
from 表名
group by class
order by class