Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Pivoting

Status
Not open for further replies.

brucegonewild

Programmer
Jan 25, 2008
22
CA
hey there,
I need to turn this following table:
Code:
Col1 |Col2 |Col3
-----|-----|----
r11  |row12|row13
-----|-----|----
r21  |row22|row23
-----|-----|----

into:
Code:
Col1 | r12 | r22 
-----|-----|----

Naturally, I would have to use "PIVOT". Except, when using the pivot functionality I have to statically include the values that will turn into the col-header. My problem is, these rows that are being pivoted, are dynamic!! I have no way of knowing what they are and therefore
Pivot (Max(Col1) for Col2 in ([r12], [r22]) will not work. I tried putting a Select * inside the "IN" section... that didn't work...

Your help is much apreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top