I have a sales table that records sale of an item. simplified version is below
| ID | ItemID | SaleTime |
|---|---|---|
| 1 | 1234 | 2020-12-01 12:44:22 |
| 2 | 1234 | 2020-12-01 17:12:22 |
| 3 | 1234 | 2020-12-02 12:44:22 |
| 4 | 1234 | 2020-12-04 17:12:22 |
i am writing a query to count items sold each day which is working fine and giving following results.
| ID | ItemID | Date | Sale count |
|---|---|---|---|
| 1 | 1234 | 2020-12-01 | 2 |
| 2 | 1234 | 2020-12-02 | 1 |
| 3 | 1234 | 2020-12-04 | 1 |
how do I include days where no sale was made with zero count like following.
| ID | ItemID | Date | Sale count |
|---|---|---|---|
| 1 | 1234 | 2020-12-01 | 2 |
| 2 | 1234 | 2020-12-02 | 1 |
| 3 | 1234 | 2020-12-03 | 0 |
| 4 | 1234 | 2020-12-04 | 1 |