结题思路:在上一题的基础上,使用case when 判定是加还是减
select id,name,grade_sum from( select *, rank() over(order by grade_sum desc) as tr from( select id,name, sum( case when type='add' then grade_num else -grade_num end ) as grade_sum from grade_info as g left join user as u on g.user_id=u.id group by id,name )t )t1 where tr=1 order by id