Results 1 to 5 of 5
  1. #1
    stefanocps is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019

    Count numer of record in query using distinct and count

    Hello i am trying to use the 2 DISTICT and COUNT together in the same query, which i use to count the number of records presents in db, but can t get
    I am able to use the distinct to eliminate DUPLICATE recors, but when try to use count somehting go wrong
    So at the moment i have to build another query that count hte 1 query
    I have the query DATETQ2
    SELECT DISTINCT date_trattamenti.ID, anagrafica.SESSO
    FROM anagrafica INNER JOIN date_trattamenti ON anagrafica.Id = date_trattamenti.ID
    GROUP BY date_trattamenti.ID, anagrafica.SESSO, date_trattamenti.dal
    HAVING (((anagrafica.SESSO) Like "Femmina") AND ((date_trattamenti.dal) Between #1/30/2018# And #12/30/2018#));
    that acccording to those date(later i ll make them variabile), select
    all the user that has been treated during that period selected for sex, male and female, in this case Female (anagrafica.SESSO) Like "Femmina)
    There are 2 table, one is Date_trattamenti with ID, FROM,TO, the last 2 are the date of start and end of treatment
    The other table is ANAGRAFICA, with detail of the patient

    Now with th e previous query i count all the female tretaed oin that range of time

    I want to count them in the same Query instead of using another query to do
    SELECT Count(dateTQ.ID) AS ConteggioDiID
    FROM dateTQ;

    how can i do that?
    thanks a lot

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Ottawa, Ontario, Canada; West Palm Beach FL

  3. #3
    stefanocps is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Quote Originally Posted by orange View Post
    You may get some ideas from the link on Counting distinct records with MS Access.
    ihave tried thoe options but don t know why for me don t work

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Nevada, USA
    Post 3 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019

  5. #5
    stefanocps is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    i have solved
    checked carefully the syntax and it is fine
    Thanks a lot

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

Similar Threads

  1. Replies: 2
    Last Post: 09-05-2014, 01:23 PM
  2. Distinct count in a query
    By Fabdav in forum Access
    Replies: 5
    Last Post: 09-14-2011, 04:53 PM
  3. Count distinct records in parameterized query
    By SilverSN95 in forum Access
    Replies: 5
    Last Post: 07-27-2010, 09:31 AM
  4. Replies: 2
    Last Post: 11-18-2009, 06:49 PM

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 - Senior Forums