我有这张桌子:
pupil_id | mark | month | year
数据:
01 | 4 | February | 2015
02 | 6 | September| 2014
01 | 3 | February | 2015
02 | 5 | September| 2014
pupil_id | month | year | sum(mark)
的预期结果是:
01 | February | 2015 | 7
02 | September | 2014 | 11
我如何总结相似的值?
答案 0 :(得分:2)
使用GROUP BY
可以为您提供所需的结果。
SELECT pupil_id, month, year, SUM(mark)
FROM marks
GROUP BY pupil_id, month, year