我有这个样子
获得最大的用户评分与分钟时间总结
scores
game_id | level | score | time
--------+-------+-------+-----
1 | 1 | 1 | 10
1 | 2 | 0 | 10
1 | 3 | 1 | 20
2 | 1 | 1 | 5
2 | 2 | 1 | 15
2 | 3 | 0 | 10
3 | 1 | 0 | 10
3 | 2 | 0 | 10
3 | 3 | 0 | 10
games
game_id | user_id
--------+--------
1 | 1
2 | 1
3 | 2
MySQL表,我需要因此总结点和每场比赛的时间来查询它,所以它看起来像这样
game_id | user_id | sumPoints | sumTime
--------+---------+-----------+--------
1 | 1 | 2 | 40
2 | 1 | 2 | 30
3 | 2 | 0 | 30
而且比我需要得到最好的成绩为每个用户(最好成绩我的意思是其中max(sumPoints)和最小(sumTime),所以它看起来是这样的:
game_id | user_id | sumPoints | sumTime
--------+---------+-----------+--------
2 | 1 | 2 | 30
3 | 2 | 0 | 30
那就是最终结果。我可以做点和时间总结的部分,但我不知道我怎么能得到每个用户的分数。 我想知道,我怎么能通过SQL查询做到这一点? 在此先感谢
我想你的意思是'2 | 1 | 2 | 30'不'1 | 1 | 2 | 30' – 2013-05-02 00:28:18