Top Competitors

  • + 0 comments

    WITH ch_counts AS ( SELECT st.hacker_id AS hacker_id, h.name AS name, COUNT(st.hacker_id) as num_challenges FROM Submissions st JOIN Challenges c ON st.challenge_id = c.challenge_id JOIN Difficulty d ON d.difficulty_level = c.difficulty_level JOIN Hackers h ON h.hacker_id = st.hacker_id WHERE st.score = d.score AND c.difficulty_level = d.difficulty_level GROUP BY st.hacker_id, h.name HAVING COUNT(st.hacker_id) > 1
    ) SELECT hacker_id, name --num_challenges FROM ch_counts ORDER BY num_challenges DESC, hacker_id