Top Competitors

  • + 0 comments

    For SQL server / MS sql

    select h.hacker_id , h.name from ( select h.hacker_id as id, count (case when s.challenge_id=s.challenge_id and c.difficulty_level=d.difficulty_level and d.score=s.score then 1 else null end ) as countofchallenges from hackers H inner join Submissions S on h.hacker_id=s.hacker_id inner join Challenges c on c.challenge_id=s.challenge_id inner join Difficulty D on c.difficulty_level=d.difficulty_level group by h.hacker_id having count (case when s.challenge_id=s.challenge_id and c.difficulty_level=d.difficulty_level and d.score=s.score then 1 else null end ) >1 ) c inner join hackers H on h.hacker_id = c.id order by countofchallenges desc , h.hacker_id