Results 1 to 6 of 6
  1. #1
    bhofmann is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    3

    Help on Total Query

    Using Access 2007...



    I have a data table with appointment dates, appointment statuses, patient names, a yes/no field and some other data not currently being used for this query. I am trying to use a query to aggregate data by week or month (I will be doing both eventually, but I am starting with weekly) to give me a numerator and a denominator based on the yes/no field.

    The first field in my query normalizes the appointment date to the date on the first day of the week (this is working as expected). The second field is a count of patient names, then I have two non-displayed fields, one for a filter on yes/no, and the other for a filter on appointment status. There are two possible appointment statuses that I want included in the query result, but I want the counts of patient names combined together for both appointment statuses. Currently the counts are separated by appointment status. I've tried two different things for the filter criteria:

    "CHECKED OUT" Or "INPATIENT APPOINTMENT"
    and
    Not "IsNull" And Not Like "*Missing*" And Not "ACTION REQUIRED"

    Both of these filter criteria give me the same result.

    How can I get the counts of patient names combined together for both appointment statuses?

    -Ben

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is the SQL of the query? It sounds like the status is in the GROUP BY clause, and you don't want it to be.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bhofmann is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    3
    Here is the SQL:

    SELECT MonthName(Month([pact7]![AppointmentDateTime]),True) AS [Month], Count(pact7.PatientName) AS Denominator
    FROM pact7
    GROUP BY MonthName(Month([pact7]![AppointmentDateTime]),True), pact7.VisitAppointmentStatus
    HAVING (((pact7.VisitAppointmentStatus)="CHECKED OUT" Or (pact7.VisitAppointmentStatus)="INPATIENT APPOINTMENT"))
    ORDER BY MonthName(Month([pact7]![AppointmentDateTime]),True);

    -Ben

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    So I see a status field in the GROUP BY clause like I mentioned. Did you try removing it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    bhofmann is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    3
    You were right. I played with this a little yesterday and this morning. I had to remove the status field from the GROUP BY section, but I also had to add it back to a WHERE section. It appears to be working as desired now. Thanks for the assistance.

    SELECT DateAdd("d",(-Weekday([pact7]![AppointmentDateTime])+1),[pact7]![AppointmentDateTime]) AS WeekBeginning, Count(pact7.PatientName) AS Denominator
    FROM pact7
    WHERE (((pact7.VisitAppointmentStatus)="CHECKED OUT" Or (pact7.VisitAppointmentStatus)="INPATIENT APPOINTMENT"))
    GROUP BY DateAdd("d",(-Weekday([pact7]![AppointmentDateTime])+1),[pact7]![AppointmentDateTime])
    ORDER BY DateAdd("d",(-Weekday([pact7]![AppointmentDateTime])+1),[pact7]![AppointmentDateTime]);

    -Ben

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site by the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Total Query
    By ccordner in forum Queries
    Replies: 3
    Last Post: 02-28-2012, 09:30 PM
  2. Total Query
    By joannakf in forum Queries
    Replies: 1
    Last Post: 12-22-2011, 05:35 PM
  3. Total Query
    By melonwand in forum Queries
    Replies: 24
    Last Post: 10-17-2011, 01:30 PM
  4. Help with Query Total
    By mohara in forum Queries
    Replies: 4
    Last Post: 08-20-2010, 02:35 PM
  5. Total a Query
    By Bridgid in forum Queries
    Replies: 0
    Last Post: 09-05-2009, 02:51 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