Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 29th, 2003, 11:13 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Removing Duplicate Fields

Hi All,

I've been working on this problem for 2 days now and I can't find a solution

I have a database in which looks a little like this

ID Name Address
1 anton 32 algi rd
2 lesly 24 smith st
3 bianca 32 algi rd
4 brian 92 faraday cres
5 bill 32 algi rd.

I want a query that will enable me to display all the names and addresses however if the Address is a duplicate (as in ID's 1, 3, 5) I don't want it to display the address 3 times. I only want it to display once.

However it gets more complicated I want one of the names (either anton bianca or lesley doesn't matter which) to show up with the address.

In other words I want the Query to output

ID Name Address
1 anton 32 algi rd
2 lesly 24 smith st
4 brian 92 faraday cres.

I have tried the

SELECT DISTINCT Address FROM Details

However I need the name and ID's to show up with the address!

Thanks very much in advance,

                                              Anton
 
Old November 29th, 2003, 11:54 PM
Authorized User
 
Join Date: Oct 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anton

First create a "totals" Query with
fields ID and Address; using Min in
the Total block for ID.

This will return something like:
ID Address
1 32 algi rd
2 24 smith st
4 92 faraday cres

Now build a second Query tying
the above back to Your origional
table to get A name for each.

Dave

 
Old December 1st, 2003, 07:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Following on from Dave's response....
You only need one query, which selects the Min ID, Min Name and GroupBy Address,
For example:
Code:
SELECT Min(id) AS id, Min(Name) AS Name, Address
FROM YourTable
GROUP BY Address;
Steven



I am a loud man with a very large hat. This means I am in charge





Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing duplicate edge elements geoGregory3 XSLT 2 February 27th, 2008 06:08 AM
Removing duplicate entries avantikad XSLT 2 January 2nd, 2008 12:29 PM
Removing duplicate Value Row milindsaraswala Excel VBA 0 November 14th, 2007 06:11 PM
Removing duplicate nodes post-process QuickSilver002 XSLT 3 April 4th, 2007 03:47 PM
Removing the Duplicate anukagni Access 3 August 31st, 2006 12:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.