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.
Above query is working while running and it is showing "Congratulations! You have passed the sample test cases." but while submitting it is showing "We couldn't process your submission. Please submit your code again".
So I added CTE and submitted in MS SQL Server since CTE wasn't working in MySQL environment.
MS SQL Server code:
with vv as
( select Challenge_id, sum(total_views) tv, sum(total_unique_views) tuv
from view_stats group by challenge_id),
ss as
( select Challenge_id, sum(total_submissions) ts, sum(total_accepted_submissions) tas
from Submission_Stats group by challenge_id)
select con.contest_id, hacker_id, name, sum(ts), sum(tas),sum(tv),sum(tuv) from contests con
inner join colleges col on con.contest_id=col.contest_id
inner join challenges chal on col.college_id=chal.college_id
left join vv on chal.challenge_id=vv.challenge_id
left join ss on chal.challenge_id=ss.challenge_id
group by con.contest_id, hacker_id, name
having sum(ts)+sum(tas)+
sum(tv)+sum(tuv)>0
order by con.contest_id;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Interviews
You are viewing a single comment's thread. Return to all comments →
Above query is working while running and it is showing "Congratulations! You have passed the sample test cases." but while submitting it is showing "We couldn't process your submission. Please submit your code again". So I added CTE and submitted in MS SQL Server since CTE wasn't working in MySQL environment.
MS SQL Server code: with vv as ( select Challenge_id, sum(total_views) tv, sum(total_unique_views) tuv from view_stats group by challenge_id), ss as ( select Challenge_id, sum(total_submissions) ts, sum(total_accepted_submissions) tas from Submission_Stats group by challenge_id) select con.contest_id, hacker_id, name, sum(ts), sum(tas),sum(tv),sum(tuv) from contests con inner join colleges col on con.contest_id=col.contest_id inner join challenges chal on col.college_id=chal.college_id left join vv on chal.challenge_id=vv.challenge_id left join ss on chal.challenge_id=ss.challenge_id group by con.contest_id, hacker_id, name having sum(ts)+sum(tas)+ sum(tv)+sum(tuv)>0 order by con.contest_id;