Hi all,
I have been at this for a bit now and just cannot get this subquery deal down for the life of me. What began as what I thought would be a simple request turned into complete brain fry. The request was to get all MTJ actual prod hours for a parent job. So, JobHead → JobMtl → JobProb (related by TargetJobNum, TargetAssySeq, and TargetMtlSeq) → JobOper with a calculated field as sum(JobOper.ActualProdHours). Works great (using the legacy IsSummary on JobMtl, JobProd and JobOper) until I run into an MTJ that is making parts for multiple materials meaning there’s more than 1 job demand link in JobProd. When this happens, I get ActualProdHours * total job demand links in JobProd.
I am sure this can be done using a subquery and not using IsSummary but I cannot figure it out for the life of me. Any help would be greatly appreciated,
@SimpsonGranco A couple of questions. Is this 9 or 10? Can you use the LLA values in JobAsmbl that Epicor builds and divide by the quantity for this top line?
So either way you will need to use Sum(JobOper.ActualProdHours) * (JobHead.ProdQty / JobProd.ProdQty)). In a sub query you would group JobProd by JobNum,TargetJobNum, TargetAssySeq, and TargetMtlSeq and then join back to the main query on the same fields.
Error when analyzing: Column ‘Erp.JobOper.ActProdHours’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Like @gpayne mentioned your subquery is the one with the error.
You can make the subquery the top query. Get the result you want and then work on the main query.
I am guessing you want the JobOper_ActProdHours, JobHeadMTJ_ProdQty, and JobProd_ProdQty to be SUM. You will need to create a calculated field for those.
Maybe this visual will help? In the below example, MTJ 35577-11-100 is making a total of 2 but 1 for 35577-11/4/1220 and another for 35577-11/5/860 on a single operation that has .98 actual production hours recorded. However, if I sum on ActualProdHours, it will double to 1.96 actual hours. If I can just get it to return 1 JobProd record, I would be perfectly fine.