Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Nonexisting field

Status
Not open for further replies.

KL_Hutchmfg

IS-IT--Management
May 2, 2018
18
US
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:
Capture_ctejay.png


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
 
I think that depends on how your Prod_Eff is calculated.

For instance, I can see that Work Centers 110 & 120 both have somewhat similar efficiencies, however the hours are vastly different. Simply averaging the two efficiencies, in this abreviated exercise, to 84 would be giving WC 110 more weight than WC 120, it seems to me.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top