Question

I am trying to do some complex pivot query... and I need to do a select in the IN Clause...

Example of the Pivot

Looking at the Example in the above link, you can see they use the employee ids explicitly in their pivot. I would like to be able to do select instead of specifying the employee ids.

The only way I can think of doing it now, is by creating my pivot query in a string and using manipulation in a Stored Prodcedure to build the employee ids into a string, insert that into my PIVOT clause, and execute the resulting SQL....

Anyone think of a better way to do this?

Was it helpful?

Solution

You pretty much have to use dynamic SQL when construction pivot queries when the pivot column contents cannot be hard coded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top