To find the earliest dated record

R

rama

Hello,
I have a table which is having few fields “Date”, “Material”, “PO”.
This table is for maintaining the material purchasing details. My
problem is same material is purchased with different PO in different
dates. I wanted to find out earliest dated PO’s of all material from
this table. I am putting some sample data here for your consideration.

Material PO Date
10192 600012 10/20/2009
10192 600009 10/6/2009
10192 600003 9/6/2009
20292 600020 10/30/2009
20292 600004 9/4/2009
20293 600013 10/30/2009

I would like to have the query result as follows

Material PO Date
10192 600003 9/6/2009
20292 600004 9/4/2009
20293 600013 10/30/2009

Thanks
Rama
 
S

Stefan Hoffmann

hi Rama,
I have a table which is having few fields “Date”, “Material”, “PO”.
This table is for maintaining the material purchasing details. My
problem is same material is purchased with different PO in different
dates. I wanted to find out earliest dated PO’s of all material from
this table. I am putting some sample data here for your consideration.
Use something like this:

SELECT O.*
FROM [yourTable] O
WHERE O.[Date] =
(
SELECT MIN(I.[Date])
FROM [yourTable] I
WHERE I.[Material] = O.[Material]
)


mfG
--> stefan <--
 
R

rama

hi Rama,
I have a table which is having few fields “Date”, “Material”, “PO”.
This table is for maintaining the material purchasing details. My
problem is same material is purchased with different PO in different
dates. I wanted to find out earliest dated PO’s of all material from
this table. I am putting some sample data here for your consideration.

Use something like this:

SELECT O.*
FROM [yourTable] O
WHERE O.[Date] =
(
   SELECT MIN(I.[Date])
   FROM [yourTable] I
   WHERE I.[Material] = O.[Material]
)

mfG
--> stefan <--

Hello,
Thank you very much for the support.
Rama
 

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