Reputation: 23
Our software currently reads square brackets [] as needing to enter a field into for the user.
I've trying to add a report in for a few users but can't get this to function properly as the PIVOT within the report won't let me remove the square brackets.
Does anyone know of a replacement for this?
PIVOT
(
SUM(A)
FOR MonthYear
IN ([01],[02],[03],[04],[05],[06],[07],[08],[09],[10],[11],[12])
)
Upvotes: 2
Views: 114
Reputation: 1270011
You can switch to conditional aggregation:
select . . . ,
sum(case when monthyear = '01' then a else 0 end) as mon_01,
sum(case when monthyear = '02' then a else 0 end) as mon_02,
. . .
from . . .
group by . . .;
Upvotes: 4