SQL Server, how to join a table in a "rotated" format (returning columns instead of rows)?
- by Joshua Carmody
Sorry for the lame title, my descriptive skills are poor today.
In a nutshell, I have a query similar to the following:
SELECT P.LAST_NAME, P.FIRST_NAME, D.DEMO_GROUP
FROM PERSON P
JOIN PERSON_DEMOGRAPHIC PD ON PD.PERSON_ID = P.PERSON_ID
JOIN DEMOGRAPHIC D ON D.DEMOGRAPHIC_ID = PD.DEMOGRAPHIC_ID
This returns output like this:
LAST_NAME …