We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SELECT h.hacker_id,
h.name,
COUNT(c.challenge_id) AS total_challenges
FROM Hackers h
JOIN Challenges c
ON h.hacker_id = c.hacker_id
GROUP BY h.hacker_id, h.name
HAVING COUNT(c.challenge_id) = (
SELECT MAX(cnt)
FROM (
SELECT COUNT() AS cnt
FROM Challenges
GROUP BY hacker_id
)
)
OR COUNT(c.challenge_id) IN (
SELECT cnt
FROM (
SELECT COUNT() AS cnt
FROM Challenges
GROUP BY hacker_id
)
GROUP BY cnt
HAVING COUNT(*) = 1
)
ORDER BY total_challenges DESC, h.hacker_id;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Challenges
You are viewing a single comment's thread. Return to all comments →
SELECT h.hacker_id, h.name, COUNT(c.challenge_id) AS total_challenges FROM Hackers h JOIN Challenges c ON h.hacker_id = c.hacker_id GROUP BY h.hacker_id, h.name HAVING COUNT(c.challenge_id) = ( SELECT MAX(cnt) FROM ( SELECT COUNT() AS cnt FROM Challenges GROUP BY hacker_id ) ) OR COUNT(c.challenge_id) IN ( SELECT cnt FROM ( SELECT COUNT() AS cnt FROM Challenges GROUP BY hacker_id ) GROUP BY cnt HAVING COUNT(*) = 1 ) ORDER BY total_challenges DESC, h.hacker_id;