Contest Leaderboard

Sort by

recency

|

2269 Discussions

|

  • + 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
    
  • + 0 comments

    select hacker_id,name, sum(max_score) from ( select h.hacker_id,h.name,s.challenge_id,max(s.score) as max_score from hackers h join submissions s on h.hacker_id=s.hacker_id group by hacker_id,name,challenge_id
    ) max_table group by hacker_id,name having sum(max_score)!=0 order by sum(max_score) desc,hacker_id

  • + 1 comment

    Can someone explain what am I doing wrong? Code:-

    select h.hacker_id,h.name,sum(s.score)
    from hackers h join Submissions s on h.hacker_id=s.hacker_id 
    where 
    score in (select max(score) from Submissions group by hacker_id,challenge_id)
    group by h.hacker_id,h.name,s.challenge_id
    having sum(s.score)>0
    order by sum(s.score) desc, h.hacker_id asc``
    
  • + 0 comments

    select hacker_id, name, sum(score) as mx from ( select h.hacker_id, h.name, s.challenge_id, max(s.score) as score from hackers h join submissions s on h.hacker_id = s.hacker_id group by h.hacker_id, h.name, s.challenge_id ) a group by hacker_id, name having mx > 0 order by mx desc, hacker_id

  • + 0 comments

    select h.hacker_id, h.name, sum(t1.max_score) as total_score from ( select s.hacker_id, s.challenge_id, max(s.score) as max_score from Submissions as s group by s.hacker_id, s.challenge_id ) as t1 join Hackers as h on h.hacker_id = t1.hacker_id group by h.hacker_id, h.name having sum(t1.max_score) > 0 order by total_score desc, h.hacker_id asc;