Você pode usar o PIVOT do SQL Server operador
SELECT *FROM ( SELECT P.ProductName , C.CustName , T.Amount FROM Transactions AS T INNER JOIN Produto AS P ON T.ProductID =P.ProductID INNER JOIN Cliente AS C ON T.CustomerID =C .CustomerID WHERE T.TranDate BETWEEN '2011-01-01' AND '2011-03-31' ) sPIVOT (SUM(Amount) FOR ProductName IN ([Car], [Cycle], [Scooter])) pvt
Dados de teste
;WITH q AS ( SELECT [Produto] ='Carro', [Cliente] ='Armstrong', [Valor] =80115.50 UNION ALL SELECT 'Carro', 'Michelle', 36571.85 UNION ALL SELECT 'Carro ', 'Schmidt', 45000,65 UNION ALL SELECT 'Ciclo', 'Michelle', 15000,00 UNION ALL SELECT 'Ciclo', 'Ronald', 25000,00 UNION ALL SELECT 'Scooter', 'Peterson', 82658,23 UNION ALL SELECT 'Scooter', 'Ronald', 98547.52 UNION ALL SELECT 'Scooter', 'Schmidt', 54000.25 )SELECT Customer , Car =ISNULL(Car, 0) , Cycle =ISNULL(Cycle, 0) , Scooter =ISNULL(Scooter, 0) , Total =ISNULL(Carro, 0) + ISNULL(Ciclo, 0) + ISNULL(Scooter, 0)FROM ( SELECT * FROM q ) sPIVOT (SUM(Amount) FOR Product IN ([Car], [Cycle], [Scooter])) pvt
Saída
Scooter do ciclo do carro do cliente TotalArMstrong 80115.50 0,00 0,00 80115.50Michelle 36571,85 15000,00 0,00 51571.85Peterson 0,00 0,00 82658.23 82658.23RONALD 0,00 25000.00 98547.523.2657.