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.
- Prepare
- SQL
- Basic Join
- Contest Leaderboard
- Discussions
Contest Leaderboard
Contest Leaderboard
Sort by
recency
|
2157 Discussions
|
Please Login in order to post a comment
SELECT h.hacker_id, h.name, SUM(s.max_score) AS total_score FROM Hackers h JOIN ( SELECT hacker_id, challenge_id, MAX(score) AS max_score FROM Submissions GROUP BY hacker_id, challenge_id ) s ON h.hacker_id = s.hacker_id GROUP BY h.hacker_id, h.name HAVING total_score > 0 ORDER BY total_score DESC, h.hacker_id ASC;
MS SQL server whats wrong in this code? with abc as ( select hackers.hacker_id, hackers.name, submissions.challenge_id, submissions.score, dense_rank() over(partition by hackers.hacker_id,submissions.challenge_id order by submissions.score desc) as ranking from hackers join submissions on hackers.hacker_id = submissions.hacker_id ) SELECT hacker_id, name, SUM(score) AS totalsum FROM abc WHERE ranking = 1 GROUP BY hacker_id, name HAVING SUM(score) > 0 ORDER BY totalsum desc,hacker_id;
MY SQL