~고군분투 인생살이~

[MEDIUM] Top Competitors 본문

SQL/HACKER_RANK

[MEDIUM] Top Competitors

소금깨 2022. 10. 26. 04:01
 

Top Competitors | HackerRank

Query a list of top-scoring hackers.

www.hackerrank.com

 

문제 조건

2개 이상의 챌린지에서 만점을 받은 참가자의 이름과 id를 출력하시오

 

만점을 받은 챌린지의 개수를 기준으로 내림차순 -> id 오름차순 

 

문제 풀이 

select h.hacker_id,
        h.name
from submissions s
    inner join hackers h on s.hacker_id = h.hacker_id
    inner join challenges c on s.challenge_id = c.challenge_id 
    inner join difficulty d on c.difficulty_level = d.difficulty_level 
where s.score = d.score 
group by h.hacker_id, h.name
having count(*) > 1 
order by count(*) desc, h.hacker_id

'SQL > HACKER_RANK' 카테고리의 다른 글

[MEDIUM] The Report  (0) 2022.10.26
[EASY] Weather Observation Station 8  (0) 2022.10.26
[EASY] Weather Observation Station 7  (0) 2022.10.26
[EASY] Weather Observation Station 6  (0) 2022.10.26
[Medium] Weather Observation Station 20  (0) 2022.10.24
Comments