Select
MONTH(VP_TOTALS.APPLYDATE) As DateMonth,
VP_TOTALS.LABORLEVELDSC2 As DepartmentNam,
VP_TOTALS.LABORLEVELNAME2 As [DepartmentNum],
VP_TOTALS.LABORLEVELDSC3 As JobNam,
VP_TOTALS.LABORLEVELNAME3 As [JobNum],
AVG(CASE WHEN VP_TOTALS.PAYCODENAME = 'Regular' THEN VP_TOTALS.WAGEAMOUNT ELSE null END) As AvgRegWages,
AVG(CASE WHEN VP_TOTALS.PAYCODENAME = 'Overtime' THEN VP_TOTALS.WAGEAMOUNT ELSE null END) As AvgOvertimeWages,
AVG(CASE WHEN VP_TOTALS.PAYCODENAME = 'Holwrkd' THEN VP_TOTALS.WAGEAMOUNT ELSE null END) As AvgHolwrkdWages
From VP_TOTALS
Where (VP_TOTALS.APPLYDATE >= Convert(DateTime,'2009-01-01 00:00:00',102) And
VP_TOTALS.APPLYDATE <= Convert(DateTime,'2009-01-31 00:00:00',102)) And
VP_TOTALS.LABORACCTID > 0
Group By
VP_TOTALS.LABORLEVELNAME3,
MONTH(VP_TOTALS.APPLYDATE),
VP_TOTALS.LABORLEVELDSC2,
VP_TOTALS.LABORLEVELDSC3,
VP_TOTALS.LABORLEVELNAME2
order by VP_TOTALS.LABORLEVELNAME3
|