Getting latest records

ds_8805

Registered User.
Local time
Yesterday, 23:01
Joined
Jan 21, 2010
Messages
70
Hello Everyone! I have a table with with details of a site. Each site is identified by its siteid. Each site id might have a few records. I want to get the latest record for each siteid. Like I have a field in the table which shows the date. I wan the lastest date for each site id. Is this possible?

Thanks!:)
 
You can do this with a aggregate query using the Max function:

SELECT SiteID, Max(myDateField) AS LatestDate
FROM myTable
GROUP BY SiteID

Replace myDateField and myTable with your equivalents.

hth
Chris
 
chris,

should be noted that it only works if there only ONE other field other than the MAX included in the query. if he wants more than two total fields, it becomes more difficult, if not impossible in a single step
 

Users who are viewing this thread

Back
Top Bottom