473,796 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return records where count is > 1 (?)

I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...
Nov 13 '05 #1
6 2141
Create a query. Pull down first name into the first field of the query grid.
Pull down class into the second field. Pull down class again into the third
field. Change the query to a totals query by clicking on the Sigma button on the
toolbar at the top of the screen. In the third field (class) where it says Group
By, use the drop down list and change it to Count. Enter =1 in the criteria of
the third field.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...

Nov 13 '05 #2
Your request is far from being crystal clear! Your table structure is not
specified and the message subject seems to be the opposite of what I
understand in your message.

If I understand correctly what you need, this should work (change field and
table name for yours):

SELECT Name, Science
FROM YourTable
GROUP BY Science
HAVING COUNT(*) = 1
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...

Nov 13 '05 #3
The only way I know of to help clear up my question is by giving an
example of what I have. (I know the table is far from being
normalized)

[table]
tbl_Classes:
Student_Name
Class_Name

[table records]
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Jason, Science
5. Betty, History
6. Larry, Biology

I need a query to return these records:
2, 4, 5

So, I need the query to return only records where the class count (?)
is only equal to one. Since "Biology" occurs in more than one record,
it is excluded from the query results.

This probably won't make sense as to what I'm doing...I'm providing a
simple example of a more complex table.

Thanks again for any help!

"Yannick Turgeon" <no****@nowhere .com> wrote in message news:<4i******* *************@n ews20.bellgloba l.com>...
Your request is far from being crystal clear! Your table structure is not
specified and the message subject seems to be the opposite of what I
understand in your message.

If I understand correctly what you need, this should work (change field and
table name for yours):

SELECT Name, Science
FROM YourTable
GROUP BY Science
HAVING COUNT(*) = 1
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...

Nov 13 '05 #4
The only way I know of to help clear up my question is by giving an
example of what I have. (I know the table is far from being
normalized)

[table]
tbl_Classes:
Student_Name
Class_Name

[table records]
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Jason, Science
5. Betty, History
6. Larry, Biology

I need a query to return these records:
2, 4, 5

So, I need the query to return only records where the class count (?)
is only equal to one. Since "Biology" occurs in more than one record,
it is excluded from the query results.

This probably won't make sense as to what I'm doing...I'm providing a
simple example of a more complex table.

Thanks again for any help!

"Yannick Turgeon" <no****@nowhere .com> wrote in message news:<4i******* *************@n ews20.bellgloba l.com>...
Your request is far from being crystal clear! Your table structure is not
specified and the message subject seems to be the opposite of what I
understand in your message.

If I understand correctly what you need, this should work (change field and
table name for yours):

SELECT Name, Science
FROM YourTable
GROUP BY Science
HAVING COUNT(*) = 1
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...

Nov 13 '05 #5
John,

Then both PC's solution and mine will work. I'll rewrite mine with your
particular fields and table name:

SELECT Student_Name, Class_Name
FROM tbl_Classes
GROUP BY Class_Name
HAVING COUNT(*) = 1
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
The only way I know of to help clear up my question is by giving an
example of what I have. (I know the table is far from being
normalized)

[table]
tbl_Classes:
Student_Name
Class_Name

[table records]
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Jason, Science
5. Betty, History
6. Larry, Biology

I need a query to return these records:
2, 4, 5

So, I need the query to return only records where the class count (?)
is only equal to one. Since "Biology" occurs in more than one record,
it is excluded from the query results.

This probably won't make sense as to what I'm doing...I'm providing a
simple example of a more complex table.

Thanks again for any help!

"Yannick Turgeon" <no****@nowhere .com> wrote in message

news:<4i******* *************@n ews20.bellgloba l.com>...
Your request is far from being crystal clear! Your table structure is not specified and the message subject seems to be the opposite of what I
understand in your message.

If I understand correctly what you need, this should work (change field and table name for yours):

SELECT Name, Science
FROM YourTable
GROUP BY Science
HAVING COUNT(*) = 1
"John" <so*********@ho tmail.com> wrote in message
news:90******** *************** ***@posting.goo gle.com...
I've got a single table I need to query to return records that have no
"related records."

Table dataset example:
1. John, Biology
2. Dave, Math
3. Susan, Biology
4. Betty, Sociology

The query should return this dataset:
2. Dave, Math
4. Bett, Sociology

Thanks for any suggestions...

Nov 13 '05 #6
Thanks for the help, Yannick and PC...I was able to use your suggestions.
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2640
by: Bryan Zash | last post by:
When querying a bit field, I am encountering a problem with MS SQL Server returning a larger number of records for a table than the actual number of records that exist within that table. For example, my customer table has 1 million unique records, so the results of the following query are as such: select count(customer_nbr) from customer = 1,000,000 There is bit field in the customer table that denotes whether a
0
1219
by: kinane3 | last post by:
I'm guessing this has something to do with my cursor but I'm not sure. this is for a picture gallery app and when I upload pictures some pictures or records don't show up. this is what ia have so far. any thoughts? this only works with an adOpenKeyset cursor by the way. use any others any it spits out errors. thanks!!! <% 'If this is the first time the page is displayed then set the record
0
2187
by: Florian | last post by:
Hi Uthuras, it would be helpful to see the access path. However sometimes it makes sense to rewrite a "not in" to gain better access paths: I tried the following - hopefully similar - statements in my environment. Watch the timerons of the different ways to get the same result set: Your Original:
0
2677
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import count automatically import and count records prompt for number of records imported import count auto-import records autoimport records count records before and after
1
15646
by: Greg Smith | last post by:
I am trying to write a SQL query that will return a record count to my C# application. I wrote the following query: ALTER PROCEDURE up_justification_duplicate AS SELECT COUNT(*) FROM tblJustifications RETURN COUNT(*)
3
1687
by: dbarker1 | last post by:
Hello All, I am developing a web front end using the standard datagrid in the 1.1 framework. Currently it allows users to navigate through records 20 at a time via previous and next buttons. This functionality is working nicely and efficiently. I like this because I dont have to grab ALL the records on each trip, just the next or previous 20. I am having a terrible time creating the exact counts for the data grid navigation. I use a...
4
5652
by: max | last post by:
I am beginning to learn sql and need some help. I have a table of customers with their addresses. Let's say I want to run a query returning the number of customers whose last name is "Smith" by state. If I use the following: SELECT customers.state, Count(*) AS FROM customers
2
3336
by: Catch_22 | last post by:
Hi, I have a stored procedure that has to extract the child records for particular parent records. The issue is that in some cases I do not want to extract all the child records only a certain number of them. Firstly I identify all the parent records that have the requird number of child records and insert them into the result table.
5
2191
by: noLoveLusT | last post by:
hi everyone i am very very new to the sql server (2 days actually and ) so far i learned creating SPs etc but couldnt workout how to get return value from my prodecure my sp as follows ________________________ CREATE PROCEDURE . @PageIndex INT, @PageSize INT, @Total INT OUTPUT
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7553
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.