Results 1 to 3 of 3
  1. #1
    Miles9999
    Guest

    Counting Unique records (Access 2000/97 SQL)

    I need help in writing an Access SQL query to give a two-column result from a Members table, listing 1. each unique country and 2. the total number of records found for each country.

    The first column is easy, using:

    SELECT DISTINCT Members.HomeCountry AS Country FROM Members;

    but I am having trouble finding out how to generate the count of Members per country in a second column. Any help is appreaciated.

    tia,
    Jon

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Counting Unique records (Access 2000/97 SQL)

    Jon,

    All you need to do is make this a Totals query. You don't need the Distinct predicate. Just set Country as a "Group By", and then do a count of members. The SQL would look like this:
    SELECT Members.HomeCountry AS Country, count(memberID) AS CountOfMembers FROM Members GROUP BY HomeCountry;
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Miles9999
    Guest

    Re: Counting Unique records (Access 2000/97 SQL)

    Mark,

    Thank you very much!

    In return, I will suggest a helpful link for syntax guides:

    <A target="_blank" HREF=http://www.devguru.com>http://www.devguru.com</A>

    Syntaxes covered:

    ADO 2.6
    ASP
    CSS2
    HTML
    JavaScript
    Jet SQL
    Transact-SQL Syntax
    VBScript
    WML
    WMLScript
    WSH
    XML DOM
    XSLT New!

    --Jon

Posting Permissions

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