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
|
2126 Discussions
|
Please Login in order to post a comment
WITH TMP as (Select hacker_id,challenge_id,max(score) as total_score from Submissions group by hacker_id, challenge_id ) Select TMP.hacker_id, H.name, Sum(TMP.total_score) as sum_score from TMP join Hackers H on TMP.hacker_id = H.hacker_id where total_score!=0 group by TMP.hacker_id, H.name ORDER BY sum_score DESC , Tmp.hacker_id ASC
I got the results with the above query. Can someone help optimize this query
Oracle: WITH cte_1 AS (select hacker_id, challenge_id, max(score) as total from submissions group by hacker_id, challenge_id) select h.hacker_id, h.name, sum(c.total) as total_score from hackers h join cte_1 c on h.hacker_id = c.hacker_id having sum(c.total) != 0 group by h.hacker_id, h.name order by total_score desc, h.hacker_id asc;
Hi guys this code is working fine but I am getting error in hacker rank `select t1.hacker_id, h.name, t1.sum from ( select t.hacker_id, sum(distinct (t.result)) as sum from ( select * ,max(score) over(partition by hacker_id,challenge_id) as result from submissions) t group by 1 having sum(distinct (t.result)) > 0 order by 2 desc, 1
) t1 left join Hackers h on h.hacker_id = t1.hacker_id `
SELECT h1.hacker_id, h2.name, h1.sumscore
FROM (
) AS max_scores
) AS h1 JOIN hackers AS h2 ON h1.hacker_id = h2.hacker_id order by h1.sumscore DESC, h1.hacker_id ASC;