im trying to put multiple sums in this pivot table but i havent been succeful,
This is the Raw data from
select
billname,
orderperiodyear,
Sum_buyprice,
Sum_Sellprice,
Tonnage
From Sum_Orders
This is my pivot how can i include buy price and tonnage in the pivot results
SELECT billname,SUM([2017])AS '2017', SUM([2016]) AS '2016'
FROM Sum_Orders
PIVOT
(
SUM(Sum_SellPrice)
FOR OrderperiodYear IN ([2017],[2016])
)AS pvt
WHERE OrderStatus IN ('Complete', 'Invoiced')
AND ( (MONTH(OrderDate) = MONTH(GETDATE()) AND day(OrderDate) <= DAY(GETDATE()))
OR MONTH(OrderDate) < MONTH(GETDATE()))
Group by BILLNAME
HAVING COALESCE(SUM([2017]), SUM([2016])) IS NOT NULL
ORDER BY BILLNAME ASC
This is what i get from my pivot
Im looking for something like this