I am trying to add missing dates to my query so that my results look like this:
10/22/2018 15
10/21/2018 0
10/20/2018 14
Rather than this:
10/22/2018 15
10/20/2018 14
I want the past 300 days listed, even if the output value is 0.
Here is my query:
SELECT TOP (300)
CAST(createddate as DATE),
count(DISTINCT ID)
FROM table
GROUP BY CAST(createddate as DATE)
ORDER BY CAST(createddate as DATE) DESC