I want to get the last 6 month count records, and show it per month. I need to show 0 in case that month doesn't have any records.
My query is
DECLARE @Date1 DATETIME, @Date2 DATETIME
SET @Date1 = GETDATE()
SET @Date2 = DateAdd(month, -6, Convert(CHAR(10), @Date1, 121))
SELECT
DATENAME(MONTH,IssueDate) [Month Name], COUNT(1) [Count]
FROM
CompetitiveProcess
WHERE
IssueDate BETWEEN @Date2 AND @Date1
GROUP BY
YEAR(IssueDate), MONTH(IssueDate), DATENAME(MONTH, IssueDate)
But is not showing the month that doesn't have any rows. Can anyone help me with this?