This is my query I want to set column names dynamically, is it possible through query
select
branch,
sum(case when months = 'JUL' then [Parts Revenue Budget] end) as [JUL]
from
#final
group by
branch
Something like this:
@Col as varchar(10);
select
branch,
sum(case when months = 'JUL' then [@Col] end) as [JUL]
from
#final
group by
branch
I get this below error message
Warning: Null value is eliminated by an aggregate or other SET operation.
Msg 207, Level 16, State 3, Procedure CRM_FRN_PL_BR_MN, Line 215
Invalid column name @Col