-- sum(if(expr,v1,v2))的妙用,用好了会提升一些写代码的效率 select id,name,grade_sum from( select u.id,u.name,sum(if(type='add',grade_num,-1grade_num)) as grade_sum, rank()over(order by sum(if(type='add',grade_num,-1grade_num)) desc ) as t_rank from grade_info g left join user u on g.user_id=u.id group by user_id orde...