标签: mysql
我的表名是HaveGoal。 我有一个包含列的表:id,week,goals 我想要一个查询,用相同的ID对所有目标进行求和,并在表格中给出数字及其总目标
答案 0 :(得分:0)
总目标:
SELECT id, SUM(goals), COUNT(goals) FROM HaveGoal GROUP BY id
每周总目标:
SELECT id, week, SUM(goals), COUNT(goals) FROM HaveGoal GROUP BY id, week