Database Programming

SQL Server: Selecting multiple rows into a single row with multiple columns

I ran into a problem writing a query today, and took the time to find the solution, so I thought I should share this with anyone who has the same problem. This solution should only work for SQL Server version 2005 and above.

The above code should result as follows:

But what if you want it as a single row with multiple columns?

This can be done by using the following solution:


Leave a Reply

Your email address will not be published. Required fields are marked *