Can I dynamically mention the columns in PIVOT clause in a SQL query?
This query is to be used in a BIP report.
SELECT MONTH, AMOUNT, COLUMN_NAME
PIVOT(SUM(AMOUNT) FORM COLUMN_NAME IN ('COL_NAME1','COL_NAME2','COL_NAME3'))
In the above example I can't predict what values will be present in the
COLUMN_NAME column. So is there any way to make column definition (the bolded part) dynamic so that I don't have to hard code the values?