https://www.hackerrank.com/challenges/15-days-of-learning-sql
SELECT submission_date,
-- total number of unique hackers
(SELECT COUNT(DISTINCT hacker_id)
FROM submissions AS sub2
-- date match
WHERE sub2.submission_date = sub1.submission_date
-- calculate the number of days from the start date
AND (SELECT COUNT(DISTINCT submission_date)
FROM submissions AS sub3
WHERE sub3.hacker_id = sub2.hacker_id
AND sub3.submission_date < sub1.submission_date) = DATEDIFF(sub1.submission_date, '2016-03-01')),
-- hacker_id and name : maximum number of submissions each day
(SELECT hacker_id
FROM submissions AS sub4
WHERE sub4.submission_date = sub1.submission_date
GROUP BY hacker_id
ORDER BY COUNT(submission_id) DESC, hacker_id
LIMIT 1) AS h_id,
(SELECT name
FROM hackers
WHERE hacker_id = h_id)
FROM (SELECT DISTINCT submission_date FROM submissions) AS sub1
처음 날짜에서는 DATEDIFF 가 0일 것이므로, 이전 제출의 수도 0이며 해당 날짜에 제출한 모든 사람을 나열합니다.