我在这里有一个数据集:
YOA Count
2014 43
2014 2
2014 17
2016 47
2015 191
2017 185
2016 26
2014 119
2016 33
我想做的是编写一个显示以下内容的SQL查询:
2017 - all counts for 2017
2016 - all counts for 2017
2015 - all counts for 2017
2014 - all counts for 2017
答案 0 :(得分:1)
试试这个:
SELECT YOA, SUM(count) total
FROM tableName
GROUP BY YOA
答案 1 :(得分:0)
将SUM
与GROUP BY
:
SELECT YOA,SUM([Count]) FROM myTable GROUP BY YOA