On Fri, 13 Jun 2008 00:29:24 -0400, "Microsoft News Server"
<(E-Mail Removed)> wrote:
>I am working with a customer database which, unfortunately, contains some
>duplicate information. Existing customers were sometimes added as new
>customers. I need to create a query which will find only the most recent
>record of each group of records which contain the same customer name. Any
>help would be appreciated. Here is an example of what I need:
>
>
>
>Existing Data
>
>Name Date Other Information
>
>Jane Smith 3/21/2004 Address, Phone, etc.
>
>Jane Smith 7/02/2006 Address, Phone, etc.
>
>Jane Smith 9/27/2007 Address, Phone, etc.
>
>Jane Smith 3/19/2008 Address, Phone, etc.
>
>John Doe 1/21/2006 Address, Phone, etc.
>
>John Doe 3/24/2007 Address, Phone, etc.
>
>John Doe 4/1/2008 Address, Phone, etc.
>
A Subquery will do this for you:
Select [Name], [Date], [Other information] FROM yourtable
WHERE [Date] =
(SELECT Max([Date] FROM yourtable AS X WHERE X.[Name] = [yourtable].[name])
Of course, it's quite possible that you have two customers with the same name
- I'm John Vinson, and when I was in school there was a Professor John Vinson
in the med school (he got one of my paychecks, alas I never got his). Also I
hope your example is hypothetical; both Name and Date are reserved words and
should not be used as fieldnames.
--
John W. Vinson [MVP]
|