473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Selecting records where a field is duplicated

MattFitzgerald
Can you help I want to reduce the number of queries I use?

I have a union query which combines data from 2 different databases located at different sites. Both databases are identical each of these databases does not allow duplication of field [Vol Ref] this does not stop their being a duplication as that Vol Ref could be entered once at each site and I have a duplicate when they are merged. I am trying to create a report that highlights duplicates. Below is the start of the code for my query:-

Expand|Select|Wrap|Line Numbers
  1. SELECT Union_Combined_Cadbury_Data.[Vol Ref], Union_Combined_Cadbury_Data.[Customer Name], Union_Combined_Cadbury_Data.[GP Agent], Union_Combined_Cadbury_Data.[Admin Agent], Union_Combined_Cadbury_Data.[Lead Product Type]
  2. FROM Union_Combined_Cadbury_Data;
how do I add Where count of [VolL Ref] >1

I know I could do this in 2 queries 1 that does a count of VOL with criteria >1 and a second that lists the details and links it by Vol Ref to the 1st query where the join looks at where the Vol Ref is exists in both queries.

I would prefer if it can be done just to use 1 query as I keep getting lost when looking at my growing number of queries which I probably could in 1 query rather than using multiple queries.

all help is much appreciated
Sep 28 '07 #1
5 1577
FishVal
2,653 Expert 2GB
Hi, Matt.

Just simple table join like this below will return you the records where field [Vol Ref] has the same value.
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON Table1.[Vol Ref]=Table2.[Vol Ref];
  2.  
Sep 28 '07 #2
NeoPa
32,556 Expert Mod 16PB
A good point from Fish.
Do you want all records with duplicates highlighted or do you just want all duplicate records (You may have answered this already but just to clarify)?
Sep 29 '07 #3
I am not looking at finding the duplicates when looking at the 2 tables. I am trying to find the duplicates in the union query that combines the 2 tables.

As I have probably confused the issue with too much detail below I have what I am looking for in the simplest terms:-

I have a query which contains a [VOL Reference] and a [GP Agent] claiming they own the order . But I have duplicates of the [VOL Reference]. What I need is a report that looks at the query and gives me a list of duplicated [VOL Reference] along with the [GP Agent] so I can go to the agents to find out who the order actually belongs to so we don't pay both for the same deal.

I have only been able to do this in 3 steps

Step 1) a query that does a count of [VOL Reference] where the count of [VOL Reference] is > 1. This givies me a list of the duplicated [VOL Reference]'s but is a summary.

Step 2) a query that links the [VOL Reference] in my original union query to the the query in "Step 1" where the join type is on [VOL Reference] where both table are equal. This gives me the detail I need [VOL Reference] along with [GP Agent].

Step 3) Have a report that pull data from query in step 2

I would idealy be able to run the report directly off my union query or at least reduce the number of queries I use?

Hope this clarifies I think my methods are probably very inefficient and create lots of queries in my database.
Oct 1 '07 #4
FishVal
2,653 Expert 2GB
Hi, Matt.

Is this from post#1 still right?

I have a union query which combines data from 2 different databases located at different sites. Both databases are identical each of these databases does not allow duplication of field [Vol Ref] this does not stop their being a duplication as that Vol Ref could be entered once at each site and I have a duplicate when they are merged.
If so inner join of two tables by the field(s) expected to have intertable duplicates would be certainly preferable. It is more simple and runs much more faster than query including aggregate functions.
Oct 1 '07 #5
NeoPa
32,556 Expert Mod 16PB
Matt,

It might be easier to start from the basic data that you hold, rather than your existing queries. Sometimes much better results can be achieved simply and directly from the data.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Oct 3 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Patrizio | last post by:
Hi All, I've the following table with a PK defined on an IDENTITY column (INSERT_SEQ): CREATE TABLE MYDATA ( MID NUMERIC(19,0) NOT NULL, MYVALUE FLOAT NOT NULL, TIMEKEY ...
1
by: Paolo | last post by:
Friends, I know I should not be doing this but I find it very usefull. I need to duplicate records from one table to another table. My table is named CLIENTS and has a field named FILENUMBER. When...
7
by: Amy | last post by:
I'm trying to add an autoincrementing id to a table based on an existing field Name, but Name has duplicated records. How can I do that in ACCESS? Thanks. Amy
1
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
1
by: Brian | last post by:
I'm trying to find a way to search multiple tables for the same record. Say I have 3 tables all with a name column, I need to search all 3 tables and find matching names. Is there an easy way to...
1
by: anonieko | last post by:
> This is a common problem with some solution > > /*********************************************************************************** * * Problem: * Determine the Duplicated Records in a...
2
by: jmarr02s | last post by:
I don't know what I am doing wrong I get duplicate records when I query Here is my SQL query code: SELECT Utilization_T.Facid, Utilization_T.Year, Utilization_T.Beds, Utilization_T.LicBeds,...
0
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.