Hello,
I am attempting to modify the below query so that the rec.DateReceived shows all of the dates received, not just the "Max" date. When I remove the "Max" part I get the error of "SubQuery Returned more than 1 value. This is knot permitted when the subquery follows =, != etc... if I rewrite the query so that it is just whreceipt.datereceipt then I get the error that the multi-part identifier could not be bound.
Any ideas?
select
pol.PONumber,
vpf.Name as 'Vendor Purchase From',
pol.Item,
pol.QuantityReceived,
(select max(rec.DateReceived)
from WHReceipt rec join WHReceiptLine recl on rec.ReceiptNumber = recl.ReceiptNumber
where rec.PONumber = pol.PONumber and recl.POLineNumber = pol.POLineNumber
) as 'date received',
pol.RequiredDate,
pol.OrderDate,
pol.PromiseDate,
pol.ExpectedDate,
(
select forecastLeadTime
from IMItemVendorLoc
where location = 'SEA'
and vendor = vpf.vendor
and item = pol.item
) as 'Forecast Lead Time'
from POPOLine pol join POPO po on pol.PONumber = po.PONumber
join APVendorPurchaseFrom vpf on vpf.VendorPurchaseFrom = po.VendorPurchaseFrom
where pol.Status <> 'CANCEL' and pol.RequiredDate >= '{[Report]!B7}'
and pol.RequiredDate < '{[Report]!B8}' and pol.ShipTo = 'SEA'
order by pol.RequiredDate, vpf.Name
I am attempting to modify the below query so that the rec.DateReceived shows all of the dates received, not just the "Max" date. When I remove the "Max" part I get the error of "SubQuery Returned more than 1 value. This is knot permitted when the subquery follows =, != etc... if I rewrite the query so that it is just whreceipt.datereceipt then I get the error that the multi-part identifier could not be bound.
Any ideas?
select
pol.PONumber,
vpf.Name as 'Vendor Purchase From',
pol.Item,
pol.QuantityReceived,
(select max(rec.DateReceived)
from WHReceipt rec join WHReceiptLine recl on rec.ReceiptNumber = recl.ReceiptNumber
where rec.PONumber = pol.PONumber and recl.POLineNumber = pol.POLineNumber
) as 'date received',
pol.RequiredDate,
pol.OrderDate,
pol.PromiseDate,
pol.ExpectedDate,
(
select forecastLeadTime
from IMItemVendorLoc
where location = 'SEA'
and vendor = vpf.vendor
and item = pol.item
) as 'Forecast Lead Time'
from POPOLine pol join POPO po on pol.PONumber = po.PONumber
join APVendorPurchaseFrom vpf on vpf.VendorPurchaseFrom = po.VendorPurchaseFrom
where pol.Status <> 'CANCEL' and pol.RequiredDate >= '{[Report]!B7}'
and pol.RequiredDate < '{[Report]!B8}' and pol.ShipTo = 'SEA'
order by pol.RequiredDate, vpf.Name