1

我正在使用用户 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

如何获得总值列?

4

1 回答 1

3
SELECT username,SUM(value) AS SumValue FROM
 table GROUP BY username ORDER BY SumValue DESC
于 2013-10-08T03:37:33.893 回答