[HR] Top Competitors*

yozzum·2022년 9월 18일

SQL

목록 보기
9/36
select h.hacker_id
      ,h.name
from hackers h
inner join (
    select hacker_id
          ,challenge_id
          ,max(score) as score
    from submissions
    group by hacker_id, challenge_id
) s
on s.hacker_id = h.hacker_id
inner join (
    select c.challenge_id
          ,c.difficulty_level
          ,d.score
    from challenges c
    inner join difficulty d
    on d.difficulty_level = c.difficulty_level
    ) t
on t.challenge_id = s.challenge_id
and t.score = s.score
group by h.hacker_id, h.name
having count(distinct t.challenge_id) > 1
order by count(distinct t.challenge_id) desc, h.hacker_id asc;
profile
yozzum

0개의 댓글