954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Select Distinct problem

I need to display multiple fields but need to restrict by the last entry for each individual.

SELECT SSAN, Location, Date_of_Trip
from TblTRIPS
Where
...only want to select the most recent trip

Need help with this. How can I restrict the select statement to the most recent trip for each individual. If I put DISTINCT in the SELECT clause I combines all the fields and give me all the trips for all the individuals...but I only want the most recent.

Thanks,
Al

teetime3
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
 
select distinct ssan, location, max(date_of_trip) from         tbltrips
group by ssan, location
__avd
Posting Genius (adatapost)
Moderator
8,647 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You