Hard - Q2

mail@pastecode.io avatar
unknown
sql
2 years ago
676 B
1
Indexable
Never
select subs.submission_date, (select count(distinct hacker_id) from submissions X where (select count(distinct submission_date) FROM submissions where hacker_id = X.hacker_id AND submission_date < subs.submission_date) = datediff(subs.submission_date, '2016/03/01') and X.submission_date = subs.submission_date) numHackers,(select hacker_id FROM submissions WHERE submission_date = subs.submission_date group by hacker_id order by COUNT(submission_id) desc, hacker_id asc limit 1) hackerID,(select name from hackers where hacker_id = hackerID) hackerName from (select distinct submission_date from submissions) subs group by subs.submission_date order by subs.submission_date;