473,396 Members | 1,678 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,396 software developers and data experts.

Trouble with Query

4
I'm trying to create a query based on a single table with 7 fields. The ID field may be the only unique field in each record. The two fields queried are Name and Action which both may appear in multiple records.

First I ran the find duplicates wizard on the name field and came up with:

Id Name Action
456 Anne a
823 Anne a
322 Anne a
45 Anne a
998 Bill a
298 Bill b
235 Bill c


From this I now need to retrieve records containing unique actions for every name:

Id Name Action
823 Anne a
998 Bill a
298 Bill b
235 Bill c

It doesn't matter which id is returned as long as for each name the action isn't duplicated.

Creating subqueries and nested queries have so far only produced errors, no output, or the same output as the first query.

Any ideas would be appreciated.

Thanks
Sep 8 '06 #1
7 1355
PEB
1,418 Expert 1GB
In fact do you need reely from the column Id in the second query? What is your need about this field?

In fact it seem that the recordset returns you the first or the last value that responds of the group But the information isn't grouped on it! It's sure! If not all records for Ann will be displayed!

Try a Group By on ID and see what will happen!
:)
Sep 8 '06 #2
kira
4
Thanks - PEB

I tried the Group By on Id and it returned the same results as first query.

To be honest I'm uncertain whether I need a second query or just need to add another statement to the first query code:

Expand|Select|Wrap|Line Numbers
  1. SELECT Summary.ID, Summary.EmployID, Summary.EmployName, 
  2. Summary.ActionCode, Summary.Location, Summary.EffDate, Summary.Unit
  3. FROM Summary
  4. WHERE (((Summary.EmployName) In (SELECT [EmployName] FROM 
  5. [Summary] As Tmp GROUP BY [EmployName] HAVING Count(*)>1 )))
  6. ORDER BY Summary.EmployName;
The records are based on actions in an employee file. A second database is about to be created and the purpose of the query is to identify employees with more than one action and list one incidence of each action associated with those employees. This information will tell us whether the associated employee file needs to be left in the original db, or moved or copied to the second.

Kira
Sep 9 '06 #3
PEB
1,418 Expert 1GB
You've done it good! :)

In fact if you have done a Group BY directly on the first query you couldn't obtain the same results that you obtain now...

Your query seems to be excelent! :)

Have a nice day and don't be uncertain ;)

Vladimir
Sep 9 '06 #4
kira
4
Hi Vladimir,

You're right. Adding a Group By on ID to the first query did produce slightly different results. It eliminated the Id column. What I meant when I said it produced the same results is it returned all the same records and didn't solve the problem with the ActionCode column.

The first query (the code in my last post) has been fine from the start. It returns all duplicate EmployNames. What I need to figure out is for each of those duplicate names how to remove any duplicate ActionCodes. For example, if there are 3 records with EmployName 'Anne' and each has an ActionCode 'a' I need to add something to the first query or have a second query that only returns one record for 'Anne' with ActionCode 'a'.

Many thanks for taking the time to reply :)

Kira
Sep 9 '06 #5
PEB
1,418 Expert 1GB
Kira,

so your code may be like:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Summary.EmployName, 
  2. Summary.ActionCode
  3. FROM Summary
  4. ORDER BY Summary.EmployName;
  5.  
Hope that is you want :)
Sep 9 '06 #6
PEB
1,418 Expert 1GB
This is equal to:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Summary.EmployName, 
  2. Summary.ActionCode
  3. FROM Summary
  4. GROUP BY Summary.EmployName, 
  5. Summary.ActionCode
  6. ORDER BY Summary.EmployName;
  7.  
Sep 9 '06 #7
kira
4
Thanks Vladimir, that's the missing piece :)

Kira
Sep 14 '06 #8

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

Similar topics

3
by: fstenoughsnoopy | last post by:
Ok the complete story. I have a Contact Table, Query and Form, that are used to input and store the contact info for customers. They have FirstName, LastName and Address as the primary key...
0
by: harry12 | last post by:
Hello- I'm fairly new at using Microsoft Access and I'm having trouble getting a couple of things to work in my database. The first is that I have yet to find a way to get an append query to...
1
by: ferraro.joseph | last post by:
Hi, I'm querying Salesforce.com via their AJAX toolkit and outputting query results into a table. Currently, their toolkit does not possess the ability to do table joins via their structured...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
5
by: tschulken | last post by:
I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml <S3Client> <Buttons>...
3
by: narpet | last post by:
Hello all... I'm having trouble with a query. Here's the situation: I have two tables, one that holds client info and another that holds invoicing info. The two tables have client number in...
1
by: =?iso-8859-1?B?RXJpYyBM83Bleg==?= | last post by:
Hello Guys! I just installed MySQL Community Server 5.0 onto my computer, which is running Red Hat 8.0 and it works fine, but I was trying to install the MySQL GUI Tools (Query Browser, MySQL...
1
by: nico3334 | last post by:
I'm having trouble with a query using "MAX". In my query I'm trying to use 2 date columns as my criteria. Here is the format for each column: Date1: 01/01/2007 Date2: 200701 For my...
3
by: lostdawg | last post by:
Hi, I am having trouble with the following query. I need to sort from a list of contacts the last date each was contacted. This is to be represented in days so for instance: 0-42 days...
1
by: George | last post by:
I have just loaded Access 2007 and am having trouble creating a new database where I update my table from a query. I have done this numerous times in years past but am totally frustrated tryng to...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.