select id,name,gn from(select id,name,gn,rank()over(order by gn desc) rk from (select user_id,sum(grade_num) gn from grade_info group by user_id) t left join user u on t.user_id=u.id) t1 where rk=1 order by id
select id,name,gn from(select id,name,gn,rank()over(order by gn desc) rk from (select user_id,sum(grade_num) gn from grade_info group by user_id) t left join user u on t.user_id=u.id) t1 where rk=1 order by id