Top Competitors

  • + 2 comments

    Do you know whether the following code is correct or not? It also pass the online test. thanks!

    SELECT h.hacker_id, h.name
    FROM Hackers h
    JOIN Submissions s ON h.hacker_id = s.hacker_id
    JOIN Challenges c ON c.challenge_id = s.challenge_id
    JOIN Difficulty d ON c.difficulty_level = d.difficulty_level
    WHERE s.score = d.score
    GROUP BY 1,2
    HAVING COUNT(DISTINCT c.challenge_id) > 1
    ORDER BY COUNT(DISTINCT c.challenge_id) DESC, h.hacker_id ASC