Results 1 to 3 of 3
  1. #1
    7mgte is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    2

    Query to Count Number of Unique Instances Across a Number of Columns

    I based the following SQL

    SELECT COUNT(*)
    FROM (
    SELECT DISTINCT c1, c2, c3 FROM myTable WHERE c5=TRUE )
    AS [SubTable]



    here: https://social.msdn.microsoft.com/Fo...um=transactsql

    For the following table

    c1 c2 c3 c5
    A B B TRUE
    A A B TRUE
    A A B TRUE
    A B B FALSE
    A A A TRUE

    it returns 3 which is the number of unique rows. What I am looking for is a query that will not only identify unique rows, but also the number of rows with the unique pattern. So for the above table, the result would be:

    A B B = 1
    A A B = 2
    A A A = 1

    Am I asking too much of SQL in MS Access? or is there a way around this?

    Any suggestions will be greatly appreciated!

    Thanks!

    Don

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    its a simple count query
    bring down the 3 fields as 1 field

    select C1 & "-" & C2 & "-" & C3 as Fld from table
    then count them
    if needed make 2 queries
    Q1 = select C1 & "-" & C2 & "-" & C3 as Fld from table

    Q2 = select Fld , count(fld) from Q1

  3. #3
    7mgte is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    2
    After some tinkering, I actually managed to do it from the query design view using a totals query. Simply did a group by on each of the fields and did a count on values in a different column of the table.

    Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Counting Instances of a Number
    By SealM in forum Queries
    Replies: 9
    Last Post: 02-04-2013, 09:35 AM
  2. Counting number of instances by time of day
    By Abarency in forum Queries
    Replies: 1
    Last Post: 11-11-2012, 04:53 PM
  3. Replies: 8
    Last Post: 03-14-2012, 05:40 PM
  4. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  5. Query Criteria: Unique Number
    By efleming in forum Access
    Replies: 1
    Last Post: 05-24-2011, 03:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums