KL_Hutchmfg
IS-IT--Management
This is my current SQL:
Select xawWorkCenterID,xawDescription,Est_Hrs,Act_Hrs,Prod_Eff From WorkCenters left outer join
(Select jmoWorkCenterID as WeekWC, (sum(jmoSetupHours)+sum(jmoEstimatedProductionHours)) as Est_Hrs, (sum(jmoActualSetupHours)+sum(jmoActualProductionHours)) as Act_Hrs,
case when sum(jmoActualProductionHours) <> 0.00 then ((sum(jmoEstimatedProductionHours)+sum(jmoSetupHours)) / (sum(jmoActualProductionHours)+sum(jmoActualSetupHours)))*100.00 else 0 end as Prod_Eff
from JobOperations where jmoProductionComplete <> 0 and exists
(select lmlTimecardID from TimecardLines where lmlActualEndTime between dateadd(ww,-6,Getdate()) and getdate() and lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID and
lmlTimecardID = (select top 1 lmlTimecardID from TimecardLines where lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID Order By lmlActualEndTime desc))
group by jmoWorkCenterID) as Week on WeekWC = xawWorkCenterID
This is how it is viewed:
My query adds a totals row with the sum of both est and act hours but I want the average of the "Prod_Eff" How can I add a row with the average of Prod_Eff? Any suggestions are helpful
Select xawWorkCenterID,xawDescription,Est_Hrs,Act_Hrs,Prod_Eff From WorkCenters left outer join
(Select jmoWorkCenterID as WeekWC, (sum(jmoSetupHours)+sum(jmoEstimatedProductionHours)) as Est_Hrs, (sum(jmoActualSetupHours)+sum(jmoActualProductionHours)) as Act_Hrs,
case when sum(jmoActualProductionHours) <> 0.00 then ((sum(jmoEstimatedProductionHours)+sum(jmoSetupHours)) / (sum(jmoActualProductionHours)+sum(jmoActualSetupHours)))*100.00 else 0 end as Prod_Eff
from JobOperations where jmoProductionComplete <> 0 and exists
(select lmlTimecardID from TimecardLines where lmlActualEndTime between dateadd(ww,-6,Getdate()) and getdate() and lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID and
lmlTimecardID = (select top 1 lmlTimecardID from TimecardLines where lmlJobID = jmoJobID and lmlJobAssemblyID = jmoJobAssemblyID and lmlJobOperationID = jmoJobOperationID Order By lmlActualEndTime desc))
group by jmoWorkCenterID) as Week on WeekWC = xawWorkCenterID
This is how it is viewed:
My query adds a totals row with the sum of both est and act hours but I want the average of the "Prod_Eff" How can I add a row with the average of Prod_Eff? Any suggestions are helpful