I have used dynamic pivot query using the script below.
select @cols = STUFF((SELECT ',' +
QUOTENAME(DATENAME(MONTH, CONVERT(DATETIME, createDate)))
FROM OSCL
GROUP BY QUOTENAME(DATENAME(MONTH, CONVERT(DATETIME, createDate)))
, DATEPART(MONTH, CONVERT(DATETIME, createDate))
ORDER BY DATEPART(MONTH, CONVERT(DATETIME, createDate))
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
, 1, 1, '');
I am getting the following result.
Description January February March April
xxxxxx 44 20 0 12
I want the following
Description January 2017 February2017 March 2017 April 2017
xxxxxx 44 20 0 12
Could you please suggest the script for this.
Thanking you,
Hem