Northwind sample view
create view PivotTest
as
select
o.customerID, c.CompanyName, p.productName, sum(od.quantity) as Qty
from
orders o
inner join
[order details] od on o.orderID = od.orderID
inner join
Products p on od.ProductID = p.ProductID
inner join
Customers c on o.CustomerID = c.CustomerID
group by
o.customerID, c.CompanyName, p.ProductName