473,403 Members | 2,284 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,403 software developers and data experts.

Duplicates in a query

Hello,
I am novice to Access and ran into dillema. I am trying to pull necessary data via query from three tables however getting dupes as a result.I tried using Distinct in SQL however it is not helping with dupes.

I have these tables:

PayrollData.tbl
JobCode.tbl
NewDeptChart.tbl

Common field that I match are:

From PayrollData.tbl to JobCode.tbl is JobCode field
From PayrollData.tbl to NewDeptChart.tbl is DeptID field

In PayrollData.tbl I have 7000 records
When I match just PayrollData.tbl with JobCode.tbl I get same count.

However, when I then add NewDeptChart.tbl I get over 60000 records in a query result.

Basically the only thing I am trying to bring from NewDeptChart.tbl is SVP Name

Here is my SQL snapshot....Please let me know if this makes sense.

Expand|Select|Wrap|Line Numbers
  1. SELECT [Payroll Data].[Employee Name]
  2.      , [Payroll Data].Title
  3.      , [Payroll Data].[Job Code]
  4.      , [Payroll Data].Division
  5.      , [Payroll Data].AllocatedCC
  6.      , [Payroll Data].[Pay Date]
  7.      , [Payroll Data].[Pay Code Description]
  8.      , [Payroll Data].Hours
  9.      , Job_Code_Productive.Bucket
  10. FROM  ([Payroll Data] LEFT JOIN 
  11.        Job_Code_Productive
  12.   ON   [Payroll Data].[Job Code] = Job_Code_Productive.[Job Code]) 
  13.        LEFT JOIN [New Dept Chart]
  14.   ON   [Payroll Data].AllocatedCC = [New Dept Chart].[Dept ID]
  15. WHERE  ((([Payroll Data].[Pay Date])=#7/22/2011#)
  16.   AND   (([Payroll Data].[Pay Code Description])<>"shift differential"));
Aug 31 '11 #1
7 1911
Narender Sagar
189 100+
Hi Yoni,
You can first make a query (lets say Query1) just with PayrollData.tbl and NewDeptChart.tbl, and bring that field (SVP Name) there. If the record count is okay, then make another query with Query1 and JobCode.tbl. I hope this will easily solve your problem.
Sep 1 '11 #2
@Narender Sagar

Thank you for your repply. I tried that and still get more records than in the payroll data. I thought I can just join three tables on specific fields and this will display data that I need? Any other suggestions?
Thanks again
Sep 1 '11 #3
Narender Sagar
189 100+
It look like Database Normalization Issue.
Please let me know, is your table NewDeptChart.tbl having unique value for each SVP name with respect to DeptID (what is SVP Name by the way.?)
Sep 1 '11 #4
@Narender Sagar
I think this table is problematic....Here is the snapshot of my relationships if this will help.....I tried to create Dept IT and SVP Name Only table to ensure that they show only unique records without dupes. But when I join them to NewDeptChart,tbl I still get dupes...
Attached Images
File Type: jpg relationships table.jpg (35.4 KB, 245 views)
Sep 1 '11 #5
Narender Sagar
189 100+
Hi Yoni,
I think, if you can share your database, I can help you to get desired result.
Sep 1 '11 #6
Rabbit
12,516 Expert Mod 8TB
Just a quick note. You said in your first post that you used DISTINCT and it still returned duplicates. That can not be true. You think it's duplicated, but it's not. At least one of the fields in your "duplicate" is different from the other "duplicate". DISTINCT will not return duplicated rows.
Sep 1 '11 #7
NeoPa
32,556 Expert Mod 16PB
Your SQL's a bit of a mess (which makes it hard for you or anyone else to work with meaningfully), but one thing I did notice was that the table [New Dept Chart] is entirely unreferenced. It should probably not even be there. You may want to try removing that and seeing how that leaves things.
Sep 1 '11 #8

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

Similar topics

3
by: Mike Blanchard | last post by:
I'm new to SQL and databases and have a delema which I'm sure is an easy thing for you experts out there to do. What I have is this: I have a table similliar to this: table name: tablename...
2
by: Sebastian | last post by:
The following query needs about 2 minutes to complete (finding dupes) on a table of about 10000 addresses. Does anyone have an idea on how to speed this up ? Thanks in advance !!! Sebastian
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
1
by: strauss.sean | last post by:
To all: Hi! I am trying to use an append queries on a table where the key field is numeric, formatted as 00-00-000. The query collects the information corectly, and there are no records...
12
by: google_groups3 | last post by:
Hi all. I currently have 2 text files which contain lists of file names. These text files are updated by my code. What I want to do is be able to merge these text files discarding the...
3
by: Georges Heinesch | last post by:
Hi. This issue semms trivial, but I didn't get it working so far. I have a database, which contains dupes. I'd like to create a query, which shows all dupes (not only one record, but all...
1
by: gdarian216 | last post by:
I am tring to get rid of dupes and his code is taking the first input and repeating it. I don't know why. this is what i have so far can anyone help #include <iostream> using namespace std; ...
4
by: kdubble | last post by:
Hi I am trying to get the results of a query to show only unique student records (not duplicates). Is there a simple way to make the criteria field do this? I am not too familiar with SQL. ...
10
by: username88 | last post by:
I am having trouble with a query for my database. It is a name & address database with columns like firstname, lastname, email, etc. I am trying to show dupes in my 20,000 name database. I have...
15
by: Yoni Hasid | last post by:
I am new to MS Access and need help. I have built multiple select quieries and when I am joining them into one query I get dupes. Question: how do I eliminate dupes on joint? Here is a sample of...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.