You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Can I dynamically mention the columns in PIVOT clause in a SQL query?

This query is to be used in a BIP report.

For Example:

SELECT MONTH, AMOUNT, COLUMN_NAME

FROM TABLE

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?

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!