Contest Leaderboard

  • + 0 comments

    can anyone please explain why this code is giving error

    with cte1 as (
    select h.hacker_id as hacker_id, 
        h.name as name, 
        s.score as score, 
        s.challenge_id as challenge_id,
        row_number() over (partition by hacker_id, challenge_id order by score) as rn
    from hackers h 
    join submissions s
    on h.hacker_id = s.hacker_id
    -- group by h.hacker_id, h.name
    )
    
    select hacker_id, name, sum(score) as total_score
    from cte1
    where rn=1
    group by hacker_id, name
    having sum(score) > 0 
    order by total_score desc, hacker_id ASC