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.
Very nice.
R can also be written using "connect by":
with R as (select submission_date, hacker_id
from submissions s
start with s.submission_date=to_date('2016-03-01','YYYY-MM-DD')
connect by s.hacker_id= prior hacker_id
and s.submission_date = prior submission_date +1),
and MaxPerDay can be written using "rank()" function
MaxPerDay as (select submission_date, hacker_id, n, rank() over (partition by submission_date order by n desc, hacker_id) rank from counter)
in the final query add "MaxPerDay.rank=1" into where clause
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
15 Days of Learning SQL
You are viewing a single comment's thread. Return to all comments →
Very nice. R can also be written using "connect by": with R as (select submission_date, hacker_id from submissions s start with s.submission_date=to_date('2016-03-01','YYYY-MM-DD') connect by s.hacker_id= prior hacker_id and s.submission_date = prior submission_date +1),
and MaxPerDay can be written using "rank()" function MaxPerDay as (select submission_date, hacker_id, n, rank() over (partition by submission_date order by n desc, hacker_id) rank from counter)
in the final query add "MaxPerDay.rank=1" into where clause