select
LastName,[1] as ContactType1,[2] as ContactType2,[3] as ContactType3,[4] as ContactType4,[5] as ContactType5
from
(select Cast(LastName as varchar(50)) as lastname,Cast(UserText10 as varchar(max)) as UserText10, row_number()Over(Partition by LastName Order by LastName) rn
from Contact) src
Pivot(max(UserText10) for rn in([1],[2],[3],[4],[5]))pvt
No comments:
Post a Comment