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

Eliminating duplicate entries by getting only the most current entry

Status
Not open for further replies.

amy3000

Technical User
Sep 25, 2000
59
US
I have a table with multiple entries for each person. There are multiples because each person may have been admitted multiple times to our agency. I have no control on how this data was set up so I'm stuck with this table.

How do I do a query in which I say I want a unique record for each person and if there are multiple entries for someone just the most current admission?
I know there must be a way to set this criteria in the admission date field of the query but I don't know how to do it. Thanks.
 
Something like this ?
SELECT A.* FROM yourTable INNER JOIN
(SELECT [person field], Max([admission date]) AS LastDate FROM yourTable GROUP BY [person field]) AS B
ON (A.[person field]=B.[person field]) AND (A.[admission date]=B.LastDate)
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PH. I did a little more searching around too before reading this. This is probably the same thing without the sql language. I did a totals query, grouped by ID number and set admission date to MAX. I don't find any duplication so it looks like it worked. That was a pretty easy one!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top