我正在使用用户Keevas的例子,但问了一个不同的问题......
select Master_Code, SUM(Jan), SUM(Feb), SUM(Mar)
from dbo.foobar
WHERE Participating_City = 'foofoo'
GROUP BY Master_Code ORDER BY Master_Code ASC
类似的东西:
Master_Code sum(Jan) Sum(Feb) sum(Mar) Total
1 4 5 4 13
2 5 5 5 15
如何获得总价值列?
答案 0 :(得分:3)
SELECT username,SUM(value) AS SumValue FROM
table GROUP BY username ORDER BY SumValue DESC