Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying for Lowest Date out of Duplicate records

Status
Not open for further replies.

opkpapp11

Programmer
Jan 31, 2008
9
US
I have a table that has a list of order information, there are multipule records per order that have information about when the order was processed. There is a day tied to the process time of each record, I need to filter out the duplicate records and get one record for an order, but that one record must be the first process time entry for that order. Anyone know how to make this query? Let me know if this doesnt make sense.
 
select orderno,min(processDate) as firstprocess
from orderprocesss
group by orderno
 
SELECT *
FROM Orders O
WHERE OrderDate = (SELECT Max(OrderDate) FROM Orders WHERE OrderNo=O.OrderNo)
 
oops, didn't notice you wanted the min date.

SELECT *
FROM Orders O
WHERE OrderDate = (SELECT MIN(OrderDate) FROM Orders WHERE OrderNo=O.OrderNo)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top