select id, name, grade_num from ( select id, name, grade_num, rank()over(order by grade_num desc) as rk from ( select id, name, sum(if(type='add',grade_num,-1*grade_num)) grade_num from grade_info g left join user u on g.user_id = u.id group by id,...