此题数据保证积分最高的用户有且只有1个——此题可以用limit找出,但是并不普适,还需要考虑并列情况!尽量用联......
select b.name, sum(a.grade_num) as grade_sum from grade_info a left join user b on a.user_id = b.id group by a.user_id order by grade_sum desc limit 1;
此题数据保证积分最高的用户有且只有1个——此题可以用limit找出,但是并不普适,还需要考虑并列情况!尽量用联......
select b.name, sum(a.grade_num) as grade_sum from grade_info a left join user b on a.user_id = b.id group by a.user_id order by grade_sum desc limit 1;