If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Counting Unique Values?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-29-04, 08:34
baynezy baynezy is offline
Registered User
 
Join Date: Jul 2004
Location: London, England
Posts: 71
Counting Unique Values?

I have a database that holds information about the location of our members. Their location is held as an ID that it gets from another table in the databse.

Is there an SQL SELECT query I can write that will return a result listing the ID and the number of times it appears? I am sure this is rather simple but I just am unaware of the code?

thanks.
__________________
Simon Baynes
www.simonbaynes.com

'The only way to discover the limits of the possible is to go beyond them into the impossible.'
Arthur C. Clarke
Reply With Quote
  #2 (permalink)  
Old 11-29-04, 08:45
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Assuming that you are using SQL, you could use the GROUP BY clause to do what you've described.

What tool(s) are you using, and what is your table design?

-PatP
Reply With Quote
  #3 (permalink)  
Old 11-29-04, 08:53
baynezy baynezy is offline
Registered User
 
Join Date: Jul 2004
Location: London, England
Posts: 71
I am using MS Access. The table has fields holding member data. All items that will potentially be repeated ie gender, location, member package, member category, etc are populated with a unique ID referencing another table containing the data that is pertinent to those. All the IDs are held in number fields.

I assume that is the info you were after?
__________________
Simon Baynes
www.simonbaynes.com

'The only way to discover the limits of the possible is to go beyond them into the impossible.'
Arthur C. Clarke
Reply With Quote
  #4 (permalink)  
Old 11-29-04, 16:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
yes, Access supports COUNT(*) and GROUP BY
Code:
select ID,count(*) as rows from sometable group by ID
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On