Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can PIVOT do this ?
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01464982
Message ID:
01464994
Views:
46
>Given a SQL2008 table structure:
>
>Id, ColumnId, RowId
>1 1 1
>2 1 2
>3 2 1
>4 2 2
>
>How do I convert it to:
>
>Row, Column1 Column2
> 1 1 3
> 2 2 4
>
>In case it's relevant the values are all GUIDS rather than ints and there will be more columns (and, obviously, rows)
>(Sorry about the spacing....)

Sure, try:
select RowID, [1] as Column1, [2] as Column2 from myTable PIVOT (Min(ID) for ColumnID in ([1],[2])) pvt
from the top of my head - not tested.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform