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
- Top Competitors
- Discussions
Top Competitors
Top Competitors
Sort by
recency
|
2505 Discussions
|
Please Login in order to post a comment
/* Enter your query here. */ SELECT hacker_id, name FROM( SELECT a.hacker_id, a.name, COUNT(DISTINCT CASE WHEN b.score = d.score THEN b.challenge_id else NULL END) AS total_perfect_score FROM Submissions b LEFT JOIN Challenges c ON b.challenge_id = c.challenge_id LEFT JOIN Difficulty d ON c.difficulty_level = d.difficulty_level LEFT JOIN Hackers a ON b.hacker_id = a.hacker_id GROUP BY 1,2) base WHERE total_perfect_score >1 ORDER BY total_perfect_score DESC, hacker_id
SELECT h.hacker_id, h.name FROM Hackers h JOIN ( SELECT DISTINCT s.hacker_id, s.challenge_id FROM Submissions s JOIN Challenges c ON s.challenge_id = c.challenge_id JOIN Difficulty d ON c.difficulty_level = d.difficulty_level WHERE s.score = d.score ) AS full_scores ON h.hacker_id = full_scores.hacker_id GROUP BY h.hacker_id, h.name HAVING COUNT(full_scores.challenge_id) > 1 ORDER BY COUNT(full_scores.challenge_id) DESC, h.hacker_id;
Oracle option
For MySQL Platform