I have a query similar to below
select type, A, B, C, D, E
from
(select type, organisation
from table1) as r
pivot
(
select sum(price)
for organisation in ([A], [B], [C], [D], [E])
) as sumofpivot
The values of column "organisation" keeps changing and so I have to again and again modify the code to include the new columns.
Is there anyway to add new columns automatically based on the values of column organisation and keep updating ?