This should get you going:declare @t as table (a int, b varchar(10), c int)insert into @t (a,b,c) values (001,'Alba',100 ), (001,'Alba',200 ), (001,'Alba',80 ), (002,'Seiko',100 ), (002,'Seiko',250 );with src as ( select a, b, c, rn=row_number() over(partition by a, b order by (select null)) from @t)select a, b, isnull([1],0) as qty1, isnull([2],0) as qyt2, isnull([3],0) as qty3from srcpivot (max(c) for rn in ([1],[2],[3])) pvt