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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to Return Latest Dated Records Among Like Key Fields 2

Status
Not open for further replies.

StarPassing

Programmer
Oct 21, 2001
109
US
Need a query that will return the latest dated record among like key fields.
Example:

Para Grade Date
1 85 04/01/04
2 92 03/28/04
1 91 03/26/04
3 90 04/02/04
2 85 03/29/04

The query should return the following.

Para Grade Date
1 85 04/01/04
2 85 03/29/04
3 90 04/02/04

Thanks
 
Hi,

presuming that Para and Date are unique it might look something like this:
Code:
SELECT	Table1.Date, Table1.Para, Table1.Grade
FROM	Table1 INNER JOIN (
SELECT	Max(Table1.Date) AS MaxOfDate, Table1.Para
FROM	Table1
GROUP	BY Table1.Para) AS d1
	ON	(Table1.Date = d1.MaxOfDate)
	AND	(Table1.Para = d1.Para);
Otherwise you'll need to use SELECT DISTINCT or DISTINCTROW or something, would need more info...
Hope this help, Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top