Select Records With Most Current Date

F

fvlmasl2

I have a table that I need to pull only the max date for each item. I will
give an example below.

Item Unit of Measure UPC Effective Date
3 EA 111 8/8/2006
3 EA 222 2/5/2006
3 EA 333 3/21/2005

5 EA 888 10/21/2006
5 EA 999 8/26/2006

With this example, the result set I would be looking for would be:

Item Unit of Measure UPC Effective Date
3 EA 111 8/8/2006
5 EA 888 10/21/2006

I have tried several methods with the DMAX function and used SQL, but I
can't seem to get a handle on it.

Any help would be greatly appreciated.
 
M

Marshall Barton

fvlmasl2 said:
I have a table that I need to pull only the max date for each item. I will
give an example below.

Item Unit of Measure UPC Effective Date
3 EA 111 8/8/2006
3 EA 222 2/5/2006
3 EA 333 3/21/2005

5 EA 888 10/21/2006
5 EA 999 8/26/2006

With this example, the result set I would be looking for would be:

Item Unit of Measure UPC Effective Date
3 EA 111 8/8/2006
5 EA 888 10/21/2006


SELECT item, unit, upc, effectivedate
FROM table
WHERE effectivedate = (SELECT Max(effectivedate)
FROM table As X
WHERE X.item = table.item)
 
F

fvlmasl2

Thank you,

I will give it a try....

Marshall Barton said:
SELECT item, unit, upc, effectivedate
FROM table
WHERE effectivedate = (SELECT Max(effectivedate)
FROM table As X
WHERE X.item = table.item)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top