创建临时表
获得积分最多的人(二)
http://www.nowcoder.com/questionTerminal/b6248d075d2d4213948b2e768080dc92
with tmp_table as ( select t1.id, t1.name, sum(t2.grade_num) as grade_sum from user as t1 join grade_info as t2 on t1.id = t2.user_id group by t1.id ) select id, name, grade_sum from tmp_table where grade_sum = (select max(grade_sum) from tmp_table) order by id;