Top Competitors

  • + 0 comments

    Your code throws an error, as h.name is not functionally dependent on the columns in the group by clause (h.name is not included in the group by clause) and to remove the redundancy just remove this condition, c.difficulty_level = d.difficulty_level. That should work. Here is my code, that worked fine for me,

    SELECT H.HACKER_ID, H.NAME FROM SUBMISSIONS S INNER JOIN CHALLENGES C ON S.CHALLENGE_ID = C.CHALLENGE_ID INNER JOIN DIFFICULTY D ON C.DIFFICULTY_LEVEL = D.DIFFICULTY_LEVEL INNER JOIN HACKERS H ON S.HACKER_ID = H.HACKER_ID
    WHERE S.SCORE = D.SCORE GROUP BY H.HACKER_ID, H.NAME HAVING COUNT(H.HACKER_ID) > 1 ORDER BY COUNT(H.HACKER_ID) DESC, S.HACKER_ID ASC