I've been trying to remove NULL values from a pivot table. I've tried several suggested solutions to without luck.
Declare @toName as nvarchar(max)
SELECT *
FROM (SELECT
isnull(protocol,0) as Protocol,
isnull(callCategory,0) as DCRCategory,
isnull(DATEPART(Year, eCreationTime),0) AS Year,
isnull(DATENAME(MONTH, eCreationTime),0) [Month],
isnull(COUNT(1),0) callCategory
FROM DCR_DATA
where ProjectManager = ''' + @toName + '''
GROUP BY protocol, callCategory, YEAR(eCreationTime), DATENAME(MONTH, eCreationTime))
AS MontlyDCRData
PIVOT(SUM(callCategory)
FOR Month IN ([January],[February],[March],[April],[May],
[June],[July],[August],[September],[October],[November],
[December])) AS MNamePivot
Here is an example of what I am returning:
Protocol DCRCategory Year January February March April May June July August September October November December
123 Cat 1 2017 NULL NULL NULL NULL NULL NULL NULL NULL 4 NULL NULL NULL