sql语句_统计总成绩最高的前2名

有一个数据表,id user_id score 三个字段,计算总成绩最高的前两名

 

SELECT * FROM
(SELECT user_name,SUM(score) AS score FROM user GROUP BY user_name) AS t
ORDER BY t.score DESC LIMIT 2

  

posted on 2016-10-13 09:29  张三的哥哥  阅读(1134)  评论(0编辑  收藏  举报