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
|
2522 Discussions
|
Please Login in order to post a comment
ORACLE
select s.hacker_id , h.name from submissions s join challenges c on s.challenge_id = c.challenge_id join difficulty d on c.difficulty_level = d.difficulty_level join hackers h on s.hacker_id = h.hacker_id where s.score = d.score group by s.hacker_id, h.name having count() > 1 order by count() desc, s.hacker_id;
select s.hacker_id, name from submissions s join hackers h on s.hacker_id = h.hacker_id join Challenges c on s.challenge_id = c.challenge_id join Difficulty d on c.difficulty_level = d.difficulty_level group by s.hacker_id, name having sum(case when s.score = d.score then 1 else 0 end)>1 order by sum(case when s.score = d.score then 1 else 0 end) desc, s.hacker_id
my sql : SELECT aaa.hacker_id, b.name FROM ( SELECT a.hacker_id, COUNT(DISTINCT a.challenge_id) AS totchal FROM submissions a LEFT JOIN challenges b ON a.challenge_id = b.challenge_id LEFT JOIN difficulty c ON b.difficulty_level = c.difficulty_level WHERE a.score = c.score GROUP BY a.hacker_id ) aaa LEFT JOIN hackers b ON aaa.hacker_id = b.hacker_id WHERE totchal > 1 ORDER BY totchal DESC, aaa.hacker_id ASC;