题解 | #获得积分最多的人(一)#
获得积分最多的人(一)
http://www.nowcoder.com/practice/1bfe3870034e4efeb4b4aa6711316c3b
SELECT t1.name name, t1.grade_sum grade_sum FROM ( SELECT t.name as name, sum(t.gnum) as grade_sum FROM ( SELECT u.name name, g.grade_num gnum FROM `user` u LEFT JOIN `grade_info` g ON u.id = g.user_id ) t GROUP BY t.name ) t1 ORDER BY t1.grade_sum DESC LIMIT 0,1