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
|
2543 Discussions
|
Please Login in order to post a comment
A bit different from other posted solutions:
Hey SQL Learners can Anyone told why this Query is wrong
SELECT h.hacker_id, h.name from hackers h join submissions s on h.hacker_id = s.hacker_id join challenges c on s.challenge_id = c.challenge_id join difficulty d on c.difficulty_level = d.difficulty_level where d.score = s.score GROUP by h.hacker_id,h.name having count(distinct s.submission_id)>1 order by count(distinct s.submission_id) desc,hacker_id asc
select hacker_id, name from (select a.hacker_id, name, count() as ct from (select s.hacker_id, c.challenge_id, d.score from Submissions s join Challenges c on s.challenge_id = c.challenge_id join Difficulty d on c.difficulty_level = d.difficulty_level) a join Submissions sub on a.hacker_id = sub.hacker_id and a.challenge_id = sub.challenge_id join Hackers h on a.hacker_id = h.hacker_id where a.score = sub.score group by 1,2 having count()>1 order by ct desc, hacker_id) ww