I just got my head around left outer joins, and I am practicing PIVOTS.
I am wondering whether it is possible to convert this query into a pivot?
SELECT mydrawercustomer.customerface,
mydrawerordertype.ordertypeface,
mydrawerorder.LM,
Datediff(hour, a1.playdate, a2.playdate) AS [RunningTime1],
Datediff(hour, a2.playdate, a3.playdate) AS [RunningTime2],
Datediff(hour, a3.playdate, a4.playdate) AS [RunningTime3],
Datediff(hour, a1.playdate, a4.playdate) AS [RunningTime4]
FROM mydrawerorder
LEFT OUTER JOIN mydrawercustomer
ON mydrawerorder.customerKEY = mydrawercustomer.customerKEY
LEFT OUTER JOIN mydrawerorderactivity a1
ON mydrawerorder.orderKEY = a1.orderKEY
AND a1.activityKEY = 1
LEFT OUTER JOIN mydrawerorderactivity a2
ON mydrawerorder.orderKEY = a2.orderKEY
AND a2.activityKEY = 2
LEFT OUTER JOIN mydrawerorderactivity a3
ON mydrawerorder.orderKEY = a3.orderKEY
AND a3.activityKEY = 3
LEFT OUTER JOIN mydrawerorderactivity a4
ON mydrawerorder.orderKEY = a4.orderKEY
AND a4.activityKEY = 4
INNER JOIN mydrawerordertype
ON mydrawerorder.ordertypeKEY = mydrawerordertype.ordertypeKEY
ORDER BY mydrawercustomer.customerface,
mydrawerordertype.ordertypeface,
mydrawerorder.LM,
a1.playdate
I'm not requesting you to solve my challenge for me, but I am just requesting help on getting started on converting this type of left outer join query into a PIVOT.