Hey everyone! Here is the problem...I am writing a stored procedure and need to restrict the number of returned records to 10 and can't seem to make it work. Here is the code:
Select
POH.PONumber,
POH.POEntryDate,
POH.DueDate,
POD.ItemCode,
POD.ItemDescription,
POD.UOMCode,
POD.DrawingNumber,
POD.ReceivedDate,
RH.ReceiverNumber,
RH.POTypeCode,
RH.VendorCode,
RD.CompanyCode,
RD.ReceiverNumber,
RD.OrderQuantity,
RD.UnitPrice
From [POHeaderHistory]POH
LEFT JOIN
[PODetailHistory]POD
ON
POH.PONumber = POD.PONumber AND
POH.CompanyCode = POD.CompanyCode
And POD.ItemCode = @ItemCode
LEFT JOIN
[ReceiverHeaderHistory]RH
ON
RH.ReceivedDate = POD.ReceivedDate AND
RH.CompanyCode = POH.CompanyCode AND
RH.VendorCode = POH.VendorCode And RH.POTypeCode = 'PO'
INNER JOIN
[ReceiverDetailHistory]RD
ON
RD.CompanyCode = POD.CompanyCode AND
RD.ReceiverNumber = RH.ReceiverNumber
AND RD.ItemCode = POD.ItemCode ORDER BY POD.RECEIVEDDATE
Any help will be greatly appreciated!
Select
POH.PONumber,
POH.POEntryDate,
POH.DueDate,
POD.ItemCode,
POD.ItemDescription,
POD.UOMCode,
POD.DrawingNumber,
POD.ReceivedDate,
RH.ReceiverNumber,
RH.POTypeCode,
RH.VendorCode,
RD.CompanyCode,
RD.ReceiverNumber,
RD.OrderQuantity,
RD.UnitPrice
From [POHeaderHistory]POH
LEFT JOIN
[PODetailHistory]POD
ON
POH.PONumber = POD.PONumber AND
POH.CompanyCode = POD.CompanyCode
And POD.ItemCode = @ItemCode
LEFT JOIN
[ReceiverHeaderHistory]RH
ON
RH.ReceivedDate = POD.ReceivedDate AND
RH.CompanyCode = POH.CompanyCode AND
RH.VendorCode = POH.VendorCode And RH.POTypeCode = 'PO'
INNER JOIN
[ReceiverDetailHistory]RD
ON
RD.CompanyCode = POD.CompanyCode AND
RD.ReceiverNumber = RH.ReceiverNumber
AND RD.ItemCode = POD.ItemCode ORDER BY POD.RECEIVEDDATE
Any help will be greatly appreciated!