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
|
2191 Discussions
|
Please Login in order to post a comment
MySQL
SELECT h.hacker_id, h.name FROM HACKERS h JOIN ( (SELECT s.hacker_id, COUNT(s.challenge_id) as full_scores FROM CHALLENGES ch JOIN DIFFICULTY d ON ch.difficulty_level = d.difficulty_level JOIN SUBMISSIONS s ON s.challenge_id = ch.challenge_id WHERE s.score = d.score GROUP BY s.hacker_id HAVING COUNT(s.challenge_id) > 1) ) AS hs ON h.hacker_id = hs.hacker_id ORDER BY hs.full_scores DESC, h.hacker_id;
THIS CODE IS GIVING RESULT IN MY SQL WORKBench but IN hACKERRANK IT IS SHOWING ERRO, why???
with full_score as (select h.name,s.challenge_id,s.hacker_id,c.difficulty_level from challenges c join submissions s on c.challenge_id=s.challenge_id join difficulty d on c.difficulty_level=d.difficulty_level and s.score=d.score join hackers h on s.hacker_id=h.hacker_id), co as (select hacker_id,row_number() over(partition by hacker_id) as cu from full_score) select distinct(hacker_id),name from ( select v.cu, f.hacker_id,f.name from co v join full_score f on f.hacker_id=v.hacker_id having v.cu > 1 order by v.cu desc,f.hacker_id)x