Top Competitors

  • + 0 comments

    MySQL:

    SELECT hacker_id, name FROM (
        SELECT H.hacker_id, name, COUNT(challenge_id) AS ct
        FROM Submissions AS S
        LEFT JOIN Hackers AS H USING (hacker_id)
        LEFT JOIN Challenges USING (challenge_id)
        LEFT JOIN Difficulty AS D USING (difficulty_level)
        WHERE S.score = D.score
        GROUP BY H.hacker_id, name HAVING ct > 1
        ORDER BY ct DESC, H.hacker_id ASC
    ) AS rankings;