select t2.date, t2.user_id, t2.sum_pass_count as pass_count from (select t1.date, t1.user_id, t1.sum_pass_count, dense_rank() over (partition by t1.date order by t1.sum_pass_count desc) rn-- 不跳数字排名 from (select date, user_id, sum(pass_count) as sum_pass_count from questions_pass_record group by user_id, date) as t1-- 考虑一个用户在同一天内刷了不同题型,所以结果前二的user-id不会是同一个人 ) as t2 where t2.rn <= 2 order by t2.date