Results 1 to 4 of 4
  1. #1
    MikeEllis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    5

    Query Unique Count

    Hi All,



    I have a simple table in a database that looks like this:

    Client # Debtor # Extract Month
    107 2567 01/2015
    107 2567 02/2015
    107 2567 03/2015
    107 2567 04/2015
    107 2575 01/2015
    107 2575 02/2015
    107 2575 03/2015
    107 2575 04/2015
    110 2125 01/2015
    110 2125 02/2015
    110 2125 03/2015
    110 2130 01/2015

    I need a query that will count the number of different debtor numbers under a given month for each client number

    It should look like the table below. Ideally without the requirement for a sub-query.


    Client # Debtor # Extract Month
    107 2 01/2015
    107 2 02/2015
    107 2 03/2015
    107 2 04/2015
    110 2 01/2015
    110 1 02/2015
    110 1 03/2015

    Any help would be much appreciated.

    Thanks

    Michael

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe you can use the Query Designer to create a Totals Query. With the designer open, click the Sigma symbol at the top right, within the Ribbon. Now you have a totals query. At the bottom of the designer window is a grid. When you have a totals query, a row will be added to the grid, I believe it says Total. Locate you field you want to Count and change Group By to Count.

    The trick to these is to not add too many fields, since you are looking for unique records. The more fields you add, the greater chance a given record will be unique and reduce your Count result.

  3. #3
    MikeEllis is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2015
    Posts
    5
    Thanks,

    Having done this I can now see that there are sometimes multiple appearances of the same debtor number within a given month.

    Theses are counted individually. I need it to consider if it is a unique debtor for the client and month...only counting it once.

    Any thoughts given this additional complication?

    Thanks

    Michael

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If it is for the month and year only, you can try applying an alias to your date field. If you have the alias, you do not want the original date field included. With your alias use the DartPart() function. In fact, you will want to use it twice for two alias'. Use DatePart() for the year and also for the month. You will need to concatenate the two together with some literal text & "/" &

    https://msdn.microsoft.com/en-us/lib...ffice.14).aspx

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

Similar Threads

  1. Replies: 3
    Last Post: 02-24-2014, 02:19 PM
  2. Another unique count question
    By atran in forum Reports
    Replies: 2
    Last Post: 05-24-2012, 10:18 AM
  3. Access Unique Count
    By spherehunter in forum Programming
    Replies: 5
    Last Post: 05-17-2012, 11:42 AM
  4. Unique queries - Unique Count
    By bigfish in forum Queries
    Replies: 7
    Last Post: 03-14-2012, 01:28 PM
  5. Count Unique Records
    By PonderingAccess in forum Queries
    Replies: 2
    Last Post: 08-19-2010, 06:54 AM

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