I have
SalesOrderId Partners PartnerType
1 A 1
1 B 2
2 X 1
2 Y 2
I need
SalesOrdeId Reseller Distrubutor ResellerType DistributorType
1 A B 1 2
2 X Y 1 2
N.B.~ Reseller Type = 1, Distributor Type = 2
Is it possible to achieve this using pivoting?
DDL
declare @t table(SalesOrderId int,Partners Varchar(10),PartnerType int)
Insert into @t values(1,'A',1),(1,'B',2),(2,'X',1),(2,'Y',2)
select *
From @t
Thanks
1 Answer