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.
15 Days of Learning SQL
15 Days of Learning SQL
Sort by
recency
|
1208 Discussions
|
Please Login in order to post a comment
SET NOCOUNT ON;
/* Enter your query here. Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error. */ with cte as ( SELECT s.submission_date, COUNT(distinct s.hacker_id) as Count_hacker_id,max(s.score) as max_score FROM Submissions s GROUP by s.submission_date)
select t.submission_date ,t.Count_hacker_id, (select top 1 s.hacker_id from Submissions s where s.score=t.max_score and t.submission_date=s.submission_date order by s.score desc ) as hacker_id, (select name from Hackers as h where hacker_id=(select top 1 s.hacker_id from Submissions s where s.score=t.max_score and t.submission_date=s.submission_date order by s.score desc )) as name from cte as t order by t.submission_date
--s.hacker_id--,h.name --, --and s.hacker_id=h.hacker_id
go
I didn't get the question, how are the number of sumbissions everyday varying? If they're daily submitters, their count would be seen daily, ie. if 4 people submitted on the 1st they'd submit even on the 2, 3 and so on. Also the min(hacker_id) is changing daily.