Skip to content
Advertisement

How to pivot two columns in SQL Server?

I have the following table

and I am trying to pivot it so that a new column is created for each username, with UserID’s listed per UserName

Advertisement

Answer

Just in case you were looking for a dynamic pivot

Example

Returns

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement