Contest Leaderboard

  • + 0 comments

    with hacker_result as (select h.hacker_id, h.name,s.challenge_id, max(s.score) as score from Hackers h inner join Submissions s on h.hacker_id = s.hacker_id group by s.challenge_id, h.hacker_id, h.name ) SELECT hr.hacker_id, hr.name, SUM(hr.score) AS total_score FROM hacker_result hr GROUP BY hr.hacker_id, hr.name HAVING SUM(CASE WHEN hr.score > 0 THEN 1 ELSE 0 END) > 0 ORDER BY total_score desc, hr.hacker_id asc;