Top Competitors [해커랭크]

dasd412·2022년 8월 2일
0

SQL

목록 보기
5/9

링크

https://www.hackerrank.com/challenges/full-score/problem?isFullScreen=true


문제 설명

Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.


코드

SELECT h.hacker_id, h.name FROM hackers h
INNER JOIN submissions s 
INNER JOIN challenges c
INNER JOIN difficulty d
ON h.hacker_id=s.hacker_id
AND s.challenge_id=c.challenge_id
AND c.difficulty_level=d.difficulty_level
WHERE s.score=d.score GROUP BY h.hacker_id, h.name HAVING COUNT(*)>=2
ORDER BY COUNT(*) DESC, h.hacker_id ASC;

profile
아키텍쳐 설계와 테스트 코드에 관심이 많음.

0개의 댓글