I have this
SELECT * FROM
(
SELECT
[cmpcode],
[el2],
[period],
[curdoc],
[valuedoc]
FROM [icarus].[dbo].[fxm_dochead_allyears_full]
WHERE [yr] = '2021' AND cmpcode = 'Z992'
) x
PIVOT
(
SUM ([valuedoc])
FOR [period] IN
([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])
)
AS pivot_table;
This works but generates lots of NULL values where there are no values for a particular month.
Where do I wrap my ISNULL? Everywhere I've tried doesn't work and if I try
ISNULL ([1], 0) AS [1]
inside of the PIVOT piece of code it errors without running.
Any help appreciated and thank you for reading.