Hi Guys, trying to extratc information about number of part produced per month and also how many were rejected. Raised the BAQ below but somehow number dont look convincing, which are the best tables to get this information?
select
[LaborDtl].[Company] as [LaborDtl_Company],
[FiscalPer].[FiscalYear] as [FiscalPer_FiscalYear],
[FiscalPer].[FiscalPeriod] as [FiscalPer_FiscalPeriod],
(SUM(LaborDtl.LaborQty)) as [Calculated_ProductionQty],
(SUM(LaborDtl.ScrapQty+LaborDtl.DiscrepQty)) as [Calculated_ScrapQty],
((
CASE
WHEN SUM(LaborDtl.LaborQty) = 0 THEN 0
ELSE
((SUM(LaborDtl.LaborQty) - SUM(LaborDtl.ScrapQty + LaborDtl.DiscrepQty))
* 100.0
/ SUM(LaborDtl.LaborQty))
END
)) as [Calculated_YieldPct]
from Erp.LaborDtl as [LaborDtl]
inner join Erp.JobHead as [JobHead] on
LaborDtl.Company = JobHead.Company
and LaborDtl.JobNum = JobHead.JobNum
inner join Erp.FiscalPer as [FiscalPer] on
LaborDtl.Company = FiscalPer.Company
and LaborDtl.PayrollDate >= FiscalPer.StartDate
and LaborDtl.PayrollDate <= FiscalPer.EndDate
and ( FiscalPer.FiscalYear = 2026 )
where (LaborDtl.LaborQty > 0
and LaborDtl.ActiveTrans = 0
and LaborDtl.LaborType = ‘P’)
group by
[LaborDtl].[Company],
[FiscalPer].[FiscalYear],
[FiscalPer].[FiscalPeriod]