Dynamic pivot
I am trying to use pivot in dynamic fashion .
I have data in
and I want to get result in this format
I have achieved this result by
select * from ( (select users, products, sale from sales))
pivot(
sum(sale) for products IN ('product 1', 'product 2', 'product 3', 'product 4', 'product 5')
)
The product range may increase rapidly in future, so I want dynamic pivoting in 'IN' clause.