Question 4 (Top Competitors)

 avatar
user_6227789376
mysql
3 years ago
444 B
4
Indexable
-- Medium
-- Question 4 (Top Competitors):


SELECT hack.hacker_id, hack.name FROM Hackers hack

JOIN Submissions subs ON hack.hacker_id = subs.hacker_id
JOIN Challenges chal ON chal.challenge_id = subs.challenge_id
JOIN Difficulty diff ON chal.difficulty_level = diff.difficulty_level

WHERE subs.score = diff.score GROUP BY 1,2 HAVING COUNT(DISTINCT chal.challenge_id) > 1

ORDER BY COUNT(DISTINCT chal.challenge_id) DESC, hack.hacker_id ASC;
Editor is loading...