I am trying to get a 30-day user report that will return the date and total number of users as an account created on that date, and I did this with this request
Select count(*) As [Count] ,
(SELECT CONVERT(date, AddDate)) As [Date]
from Users
WHERE AddDate >= (SELECT DateAdd(month, -1, Convert(date, GetDate())))
Group By CONVERT(date, AddDate)
it gives me only the dates on which any user is created, but I want to show all 30 days if it has count 0 .
The same case that I want to do with the monthly report. I get the months in which users are created, now I want to change it to get the last 12 months from this month and their total number of users . For this I use this query
Select count(*) As [Count] ,
(Select DATEPART( month , DateAdd( month , DATEPART(mm,AddDate) , -1 ) )) as Month
from Users
WHERE AddDate >= (SELECT DateAdd(YEAR, -1, Convert(date, GetDate())))
Group By DATEPART(mm,AddDate)