Hello,Having some trouble making a pivot table. It is a dynamic pivot on dates. The user will submit the date range on which the table will be pivoted.Here's the query I'm using to get the data for the pivot:SELECT HW.Date, LMM.LMDesc, E.lastName + ', ' + E.firstName AS Name, SUM(LA.units)/SUM(HW.HoursWorked) AS UPHFROM vHoursWorkedNSS AS HW LEFT OUTER JOIN tblEmployee AS E ON E.employeeID = HW.employeeID LEFT OUTER JOIN tblLineAssignment AS LA ON LA.lineAssignmentID = HW.lineAssignmentID LEFT OUTER JOIN tblLMMap AS LMM ON LMM.workTypeID = HW.workTypeID AND LMM.clientLocID = 18WHERE (HW.Date BETWEEN '08/02/2010' AND '08/20/2010') AND (LA.clientLocID = 18)GROUP BY LMM.LMDesc, HW.Date, E.lastName + ', ' + E.firstNameORDER BY HW.Date, LMM.LMDesc, Name
Here is the result table (truncated):DATE LMDesc Name UPH---------- ---------- -------- ------ 08/02/2010 03 Pick NAME1 915.89293808/02/2010 03 Pick NAME2 1014.55696208/02/2010 05 Replenish NAME3 8.40215408/03/2010 03 Pick NAME1 923.58974308/03/2010 03 Pick NAME2 617.707
This is what the table should look like after pivot on date:LMDesc Name 08/02/2010 08/03/2010------- ------- ----------- ------------03 Pick Name1 915.892938 923.58974303 Pick Name2 1014.556962 617.70705 Replenish Name3 8.402154 NULL
But I can't figure out how to do the pivot :( Any assistance will be greatly appreciated. Thanks for your time,Sean