SQL question

  • Thread starter Thread starter DBARNETT
  • Start date Start date
D

DBARNETT

Hi

I have a table with an ITM_NO and a PO_Date and a few other fields.
There are duplicate Table entries with the same ITM_NO and different
PO_Dates.

What I need to do is get 1 table entry for each Unique ITM_NO but the
entry that has the most recent PO_Date.

ITM_NO PO_DATE OTHER
123 1/27/2006 a
123 6/20/2006 b
123 5/14/2005 c

456 3/15/2007 d
456 4/15/2007 e
456 5/15/2007 f

Should yield:
123 6/20/2006 b
456 5/15/2007 f

Thanks for your help
Dennis
 
What I need to do is get 1 table entry for each Unique ITM_NO but the
entry that has the most recent PO_Date.

ITM_NO PO_DATE OTHER

A Subquery will do this:

SELECT ITM_NO, PO_DATE, OTHER
FROM mytable
WHERE PO_DATE = (SELECT Min(PO_DATE FROM mytable AS A
WHERE A.ITM_NO = mytable.ITM_NO);


John W. Vinson[MVP]
 

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

Back
Top