Hi,
I'm trying to create a query that selects the most recent record from a table containing duplicate records based on Item Code.
I keep getting a syntax error:
Code:
SELECT DUPES.id, DUPES.[Item Code], DUPES.[Date Delivered], DUPES.[Item Description], DUPES.[Received Qty], DUPES.Vendor, DUPES.Comments, DUPES.[Doc #], DUPES.Weight, DUPES.PO, DUPES.[Date Posted to Inventory], DUPES.[Time of Posting], DUPES.[Date Delivered 2], DUPES.[Time of Delivery], DUPES.[0-4 Hours Posting Delay], DUPES.[4-8 Hours Posting Delay], DUPES.[8-24 Hours Posting Delay], DUPES.[Over 24 Hours Posting Delay]
FROM DUPES
WHERE ((DUPES.[Date Delivered]<=#3/31/2011#))
(SELECT MAX(DUPES.[Date Delivered])
FROM DUPES AS X
WHERE X.[Item Code] = DUPES.[Item Code]);
The table is something like this:
ITEM CODE|Date Received|Info1|Qty
Item A|03/01/2011|This is item A|300
Item A|03/28/2011|This is item A|200
Item A|02/27/2010|This is item A|3
Item B|03/03/2011|This is item B|200
Item B|03/27/2011|This is item B|2
The results should be:
Item A|03/28/2011|This is item A|200
Item B|03/27/2011|This is item B|2
I appreciate anyone's help!!! Thank you