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.
My code gives me the wrong answer, can anyone debug for me please? Thanks;
SELECT c.contest_id,
c.hacker_id,
c.name,
SUM(s.total_submissions) AS total_submissions,
SUM(s.total_accepted_submissions) AS total_accepted_submissions,
SUM(v.total_views) AS total_views,
SUM(v.total_unique_views) AS total_unique_views
FROM Contests c
INNER JOIN Colleges col USING (contest_id)
INNER JOIN Challenges ch USING (college_id)
LEFT JOIN View_Stats v USING (challenge_id)
LEFT JOIN Submission_Stats s USING (challenge_id)
GROUP BY 1, 2, 3
HAVING
NOT (
SUM(s.total_submissions) = 0 AND
SUM(s.total_accepted_submissions) = 0 AND
SUM(v.total_views) = 0 AND
SUM(v.total_unique_views) = 0
)
ORDER BY 1;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Interviews
You are viewing a single comment's thread. Return to all comments →
My code gives me the wrong answer, can anyone debug for me please? Thanks;
SELECT c.contest_id, c.hacker_id, c.name, SUM(s.total_submissions) AS total_submissions, SUM(s.total_accepted_submissions) AS total_accepted_submissions, SUM(v.total_views) AS total_views, SUM(v.total_unique_views) AS total_unique_views FROM Contests c INNER JOIN Colleges col USING (contest_id) INNER JOIN Challenges ch USING (college_id) LEFT JOIN View_Stats v USING (challenge_id) LEFT JOIN Submission_Stats s USING (challenge_id) GROUP BY 1, 2, 3 HAVING NOT ( SUM(s.total_submissions) = 0 AND
SUM(s.total_accepted_submissions) = 0 AND SUM(v.total_views) = 0 AND SUM(v.total_unique_views) = 0 ) ORDER BY 1;