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
有一个数据表,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