Results 1 to 3 of 3
  1. #1
    DeanMcK is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2020
    Posts
    4

    Count Distinct by Month(SQL)

    Hi All,

    I have created a database that I need to identify the unique users by month.


    When is the column that holds the date. I have converted by using YEAR and MONTH and I need to do a count a unique count of USERUUID

    This is the code I have used so far but keep getting syntax errors.


    SELECT Year([When]) AS [YEAR], Month([When]) AS [Month], Count(qry1_UserUuid_Removal.USERUUID)FROM (SELECT Year,
    Month,


    USERUUID

    From qry1_UserUuid_Removal


    GROUP BY Year([When]),
    Month([When]) AS T
    Any help is appreciated.

    Cheers

    DeanMcK

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Stop using code,use a query. It won't get it wrong.
    make Q1 to pull the data range you want,
    then make Q2 that uses Q1 to count the unique. Set Unique values =true.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    your sub query is not grouping on USERUUID. And where does [When] come into it

    Agree with Ranman - use the query builder to create your sql

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

Similar Threads

  1. Replies: 0
    Last Post: 02-11-2020, 08:12 PM
  2. Replies: 4
    Last Post: 01-15-2019, 11:50 AM
  3. Distinct Count
    By ertweety in forum Queries
    Replies: 1
    Last Post: 04-15-2014, 10:10 AM
  4. Count Distinct
    By Newbie11 in forum Reports
    Replies: 8
    Last Post: 01-09-2013, 12:47 PM
  5. Distinct count in a query
    By Fabdav in forum Access
    Replies: 5
    Last Post: 09-14-2011, 04:53 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