🤔 문제 분석
1. Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge.
2. Order your output in descending order by the total number of challenges in which the hacker earned a full score
3. 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 AS H
INNER JOIN Submissions AS S ON H.hacker_id = S.hacker_id
INNER JOIN Challenges AS C ON S.challenge_id = C.challenge_id
INNER JOIN Difficulty AS D ON C.difficulty_level = D.difficulty_level
WHERE D.score = S.score
GROUP BY H.hacker_id, H.name
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC, H.hacker_id
'코딩테스트 > 해커랭크 SQL' 카테고리의 다른 글
[해커랭크/MySQL] 41. Weather Observation Station 15 (0) | 2023.03.21 |
---|---|
[해커랭크/MSSQL] 40. Ollivander's Inventory (0) | 2023.03.21 |
[해커랭크/SQL] 38. Contest Leaderboard (0) | 2023.03.17 |
[해커랭크/SQL] 37. The Report (0) | 2023.03.16 |
[해커랭크/SQL] 36. Weather Observation Station 18 (0) | 2023.03.16 |
댓글