So I am banging my head on the wall over this problem, and thought I could use some help.
I have a table: Submissions, which as follows:
+-----------------+---------------+-----------+-------+
| submission_date | submission_id | hacker_id | score |
+-----------------+---------------+-----------+-------+
| 2016-03-01 | 8494 | 20703 | 0 |
| 2016-03-01 | 22403 | 53473 | 15 |
| 2016-03-01 | 23965 | 79722 | 60 |
| 2016-03-01 | 30173 | 36396 | 70 |
| 2016-03-02 | 34928 | 20703 | 0 |
| 2016-03-02 | 38740 | 15758 | 60 |
| 2016-03-02 | 42769 | 79722 | 25 |
| 2016-03-02 | 44364 | 79722 | 60 |
| 2016-03-03 | 45440 | 20703 | 0 |
| 2016-03-03 | 49050 | 36396 | 70 |
| 2016-03-03 | 50273 | 79722 | 5 |
| 2016-03-04 | 50344 | 20703 | 0 |
| 2016-03-04 | 51360 | 44065 | 90 |
| 2016-03-04 | 54404 | 53473 | 65 |
| 2016-03-04 | 61533 | 79722 | 45 |
| 2016-03-05 | 72852 | 20703 | 0 |
| 2016-03-05 | 74546 | 38289 | 0 |
| 2016-03-05 | 76487 | 62529 | 0 |
| 2016-03-05 | 82439 | 36396 | 10 |
| 2016-03-05 | 90006 | 36396 | 40 |
| 2016-03-06 | 90404 | 20703 | 0 |
+-----------------+---------------+-----------+-------+
I am trying to get the hacker_id and the number of contributions of the top contributor each day. This is where I'm at right now:
SELECT submission_date
, hacker_id
, COUNT(hacker_id)
FROM Submissions
GROUP
BY hacker_id
, submission_date
ORDER
BY COUNT(submission_id) DESC
, HACKER_ID;
Which gives me the number of contributors each contributor makes each day, but not an organized table with a single line per day that I am looking for. Any idea how to improve my code?