Top Competitors

  • + 0 comments

    The correct one :::

    SELECT H.hacker_id, H.name FROM Hackers AS H JOIN Submissions AS S ON H.hacker_id = S.hacker_id JOIN Challenges AS C ON S.challenge_id = C.challenge_id JOIN Difficulty AS D ON C.difficulty_level = D.difficulty_level WHERE S.score = D.score GROUP BY H.hacker_id, H.name HAVING COUNT(DISTINCT S.challenge_id) > 1 ORDER BY COUNT(DISTINCT S.challenge_id) DESC, H.hacker_id ASC;

    Correct relationship path (used by working queries): Hackers (h) —(h.hacker_id = s.hacker_id)—> Submissions (s) —(s.challenge_id = c.challenge_id)—> Challenges (c) —(c.difficulty_level = d.difficulty_level)—> Difficulty (d) Your path: Hackers (H) —(H.hacker_id = C.hacker_id)—> Challenges (C) —(C.difficulty_level = D.difficulty_level)—> Difficulty (D) —(C.challenge_id = S.challenge_id)—> Submissions (S)

    I was using a different story of joinsas i got inspired by the answer here but did not give full understanding. I also thought and connecting Hackers and Submissions will work but missed the point of MAX score