Contest Leaderboard

  • + 0 comments
    with cte as(
    select hackers.hacker_id as id,hackers.name as name,submissions.challenge_id as ch_id ,submissions.score as score,
    row_number() over (partition by hackers.hacker_id,submissions.challenge_id order by submissions.score desc) as rn from hackers
    inner join submissions
    on hackers.hacker_id=submissions.hacker_id
    )
    select cte.id,cte.name,sum(cte.score) as sm from cte
    where cte.rn=1
    group by cte.name,cte.id
    having sum(cte.score)>1
    order by sm desc,cte.id asc;