最简单的做法 用with创建一个临时表,存放每个用户的总分,统计总分时用if判断type类型 将user与临时表进行关联,用where筛选总分最高的用户 SQL: with t as( select user_id,sum(if(type='add',grade_num,-grade_num)) grade_num from grade_info group by user_id) select id,name,grade_num from user u join t on u.id=t.user_id where t.grade_num =(select max(grade_num)...