Hi All
I have cobbled together a sub con received BAQ it works great but im getting duplicates data i test the the baq.
Any help would be great i betting is something really simple Ive missed
[RcvDtl].[PONum] as [RcvDtl_PONum],
[RcvDtl].[POLine] as [RcvDtl_POLine],
[Vendor].[Name] as [Vendor_Name],
[RcvDtl].[ReceiptDate] as [RcvDtl_ReceiptDate],
[RcvDtl].[PackSlip] as [RcvDtl_PackSlip],
[RcvDtl].[PartNum] as [RcvDtl_PartNum],
[RcvDtl].[PartDescription] as [RcvDtl_PartDescription],
[RcvDtl].[OurQty] as [RcvDtl_OurQty],
(PORel.RelQty - PORel.ReceivedQty) as [Calculated_OutstandingQty],
[RcvDtl].[JobNum] as [RcvDtl_JobNum],
[RcvDtl].[LotNum] as [RcvDtl_LotNum],
[RcvDtl].[InspectionReq] as [RcvDtl_InspectionReq],
[POHeader].[OrderDate] as [POHeader_OrderDate],
[SubShipD].[PackNum] as [SubShipD_PackNum],
(case
when PORel.DueDate IS NULL then
case
when PODetail.DueDate IS NULL then
case
when PORel.DueDate IS NULL then
POHeader.DueDate
else
PORel.DueDate
end
else
PODetail.DueDate
end
else
PORel.DueDate
end) as [Calculated_DueDate]
from Erp.RcvDtl as RcvDtl
inner join Erp.RcvHead as RcvHead on
RcvDtl.Company = RcvHead.Company
and RcvDtl.VendorNum = RcvHead.VendorNum
and RcvDtl.PurPoint = RcvHead.PurPoint
and RcvDtl.PackSlip = RcvHead.PackSlip
inner join Erp.Vendor as Vendor on
RcvHead.Company = Vendor.Company
and RcvHead.VendorNum = Vendor.VendorNum
inner join Erp.PODetail as PODetail on
RcvDtl.Company = PODetail.Company
and RcvDtl.PONum = PODetail.PONUM
and RcvDtl.POLine = PODetail.POLine
inner join Erp.PORel as PORel on
PODetail.Company = PORel.Company
and PODetail.PONUM = PORel.PONum
and PODetail.POLine = PORel.POLine
inner join Erp.SubShipD as SubShipD on
PORel.PONum = SubShipD.PONum
and PORel.POLine = SubShipD.POLine
and PORel.PORelNum = SubShipD.PORelNum
left outer join Erp.POHeader as POHeader on
POHeader.Company = PODetail.Company
and POHeader.PONum = PODetail.PONUM
and ( POHeader.OpenOrder = 1 )
where (RcvDtl.JobNum <> '""')