Created
April 8, 2016 15:09
-
-
Save stevenh77/acc301a0b58d34b18829a4ffe9f47ec5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from | |
( select | |
person, | |
country, | |
'country' + cast(rank() | |
over (partition by person order by id) | |
as varchar(10)) | |
as countryrank | |
from dbo.Source_Table) as rankedSource | |
pivot | |
( max (country) for countryrank in (country1, country2)) as pivottable | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment