Results 1 to 5 of 5
  1. #1
    mosheva is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    8

    Filter by date and then count

    Hi,


    I need to create a query that will return and count data from specific month.

    I first create a filter by a criteria >6, that will return the month from June (and up).
    Next:
    On each date there are 4 categories that I need them to be counted.

    When I run the query I get a count for each month times 4 categories.

    I want the query to sum all of the month than return only a count for the 4 categories.

    Here is what I get:
    Month status final plan of action (categories) count
    7 Closed PS Replacement 10
    7 Closed Upper Unit Replacement 5
    7 Closed SW Release 7
    7 Closed Lower Unit Replacement 9
    8 Closed PS Replacement 15
    8 Closed Upper Unit Replacement 3
    8 Closed SW Release 8
    8 Closed Lower Unit Replacement 7
    9 Closed PS Replacement 16
    9 Closed Upper Unit Replacement 10
    9 Closed SW Release 1
    9 Closed Lower Unit Replacement 2

    And what I need:
    Month status final plan of action (categories) count
    7+8+9 Closed PS Replacement 41
    7+8+9 Closed Upper Unit Replacement 18
    7+8+9 Closed SW Release 16
    7+8+9 Closed Lower Unit Replacement 18

    How can I make it happen?

    Thanks!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    PLease post the sql of your current Query. A jpg of your tables and relationships would also help.

  3. #3
    mosheva is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    8
    Hן,
    I didn't build it in SQL, I have built it with the Access query designer.
    All the data is on the same data base so there is no relationships...

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Hmmm,
    I don't have acc2010. Go to your query wizard, look at your query design, then look for a tab or control that says SQL View. Click it.

    Copy and post what you find.

    How many tables do you have?

  5. #5
    mosheva is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    8
    Hi,
    There is only 1 table which hold the DB
    Here is the code:
    Code:
    SELECT tblServiceRequest.Location, Month([Actual Open Date]) AS Grouping, tblServiceRequest.Type, tblServiceRequest.Status, tblServiceRequest.[Final Plan Of Action], Count(tblServiceRequest.[Final Resolution]) AS [CountOfFinal Resolution]
    FROM tblServiceRequest
    GROUP BY tblServiceRequest.Location, Month([Actual Open Date]), tblServiceRequest.Type, tblServiceRequest.Status, tblServiceRequest.[Final Plan Of Action], Month([Actual Open Date])
    HAVING (((tblServiceRequest.Location)=[Select Location 1 or 2]) AND ((Month([Actual Open Date]))=[select month]) AND ((tblServiceRequest.Type)="Problem") AND ((tblServiceRequest.Status)="Closed") AND ((Month([Actual Open Date]))>6));
    TNX!

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

Similar Threads

  1. not count date fields if the same
    By Icky_Joe in forum Queries
    Replies: 2
    Last Post: 04-11-2012, 12:55 PM
  2. Count records since date
    By sotssax in forum Queries
    Replies: 10
    Last Post: 03-07-2012, 07:30 PM
  3. distinct count with criteria and max date
    By TheShabz in forum Queries
    Replies: 3
    Last Post: 09-23-2011, 06:08 AM
  4. Count Restricted by Date
    By cgjames in forum Queries
    Replies: 3
    Last Post: 01-19-2011, 04:41 PM
  5. Count Down and close on date code
    By ibraomer in forum Programming
    Replies: 1
    Last Post: 01-03-2011, 08:58 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