Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Location
    London, England
    Posts
    71

    Unanswered: 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

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    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

  3. #3
    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

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, Access supports COUNT(*) and GROUP BY
    Code:
    select ID,count(*) as rows from sometable group by ID
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •