Top Competitors

  • + 3 comments

    why I am getting wrong answer even if I am getting same output as correct answer. Please help me to get rid of this. Here is my query

    SELECT CONCAT(FINAL_TABLE.H_ID, " ", HACKERS.NAME) AS result
    FROM HACKERS
    JOIN (
        SELECT Submissions.HACKER_ID AS H_ID, COUNT(*) AS MAXSCORE_COUNT
        FROM Submissions
        JOIN (
            SELECT CHALLENGES.CHALLENGE_ID AS C_ID, DIFFICULTY.SCORE AS MAX_SCORE
            FROM CHALLENGES
            INNER JOIN DIFFICULTY ON CHALLENGES.DIFFICULTY_LEVEL = DIFFICULTY.DIFFICULTY_LEVEL
        ) AS MAX_TABLE ON MAX_TABLE.C_ID = Submissions.CHALLENGE_ID
        WHERE SUBMISSIONS.SCORE = MAX_TABLE.MAX_SCORE
        GROUP BY Submissions.HACKER_ID
        HAVING MAXSCORE_COUNT > 1 -- Filter hackers who achieved full scores for more than one challenge
    ) AS FINAL_TABLE ON FINAL_TABLE.H_ID = HACKERS.HACKER_ID
    ORDER BY FINAL_TABLE.MAXSCORE_COUNT DESC, HACKERS.NAME;