I am clueless how can I write a (MySQL) query for this. I am sure it is super simple for an experienced person.
I have a table which summarizes sold items per day, like:
date | item | quantity |
---|---|---|
2020-01-15 | apple | 3 |
2020-01-15 | pear | 2 |
2020-01-15 | potato | 1 |
2020-01-14 | orange | 3 |
2020-01-14 | apple | 2 |
2020-01-14 | potato | 2 |
2020-01-13 | lemon | 5 |
2020-01-13 | kiwi | 2 |
2020-01-13 | apple | 1 |
I would like to query the N top sellers for every day, grouped by the date DESC, sorted by date and then quantity DESC, for N = 2 the result would look like:
date | item | quantity |
---|---|---|
2020-01-15 | apple | 3 |
2020-01-15 | pear | 2 |
2020-01-14 | orange | 3 |
2020-01-14 | apple | 2 |
2020-01-13 | lemon | 5 |
2020-01-13 | kiwi | 2 |
Please tell me how can I limit the returned item count per date.