Top Competitors

  • + 1 comment

    Hi!

    This seems to be working. which I basically used a lot of your code to write my code but I dont think I really know whats happening. In particular when I remove the 'group by' command I expect to get a lot more records (since we are not grouping anymore) but I get only one record and I dont understand why. Can you please explain whats happening here? thanks

    select s.hacker_id, h.name from submissions s
        inner join hackers h on s.hacker_id = h.hacker_id
        inner join challenges c on c.challenge_id = s.challenge_id
        inner join difficulty d on d.score = s.score
        where d.difficulty_level=c.difficulty_level
        group by s.hacker_id
        having count(*) > 1
        order by
            count(*) desc, s.hacker_id asc