for this create dynamic query. a loop that will create a pivot query.
e.g.,
Create table #t1
(
IdInt Identity(1,1),
ProductVarchar(15),
CompanyVarchar(15),
StockInt
)
GO
Insert into #t1
Values('Pen', 'Renold', 100),
('Pen', 'Cello', 100),
('Pen', 'Lexi', 100)
Select Row_Number() Over(order by Company) Id, *...