Results 1 to 4 of 4
  1. #1
    CannotAccess is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Aug 2020
    Posts
    2

    Access query question simplification - finding average for each type for every week

    Hello!



    I’m trying to simplify my query design. As of now I have individual queries that have the criteria for each week that I’m looking for. Is there a way to retrieve average repair times for each repair type for each week of the year without creating a million query’s?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you make 1 query, and feed it the date range.
    in a form put 2 text boxes: txtStartDate, txtEndDate

    the query will read them:
    select Avg(field) ,Client from table where [DateFld] between forms!fMyForm!txtStartDate and forms!fMyForm!txtEndDate

    set the dates in the boxes, then open the query.

  3. #3
    CannotAccess is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Aug 2020
    Posts
    2
    And this will work for multiple weeks?

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    if you want multiple weeks, group the week as well

    Code:
    SELECT repairType, datepart("yyyy",repairdate) as Yr, datepart("ww",repairdate) as Week, Avg(repairTime) as avgRepairTime
    FROM myTable
    GROUP BY repairType, datepart("yyyy",repairdate), datepart("ww",repairdate)


    You haven't provided details of your tables or said how you define a week so you may need to adapt this code in some way

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

Similar Threads

  1. Finding Weighted Grade Average
    By MichaelA in forum Queries
    Replies: 3
    Last Post: 10-14-2019, 06:13 AM
  2. Finding Median Average Number of days at a place
    By 5pac3m0nk3y in forum Access
    Replies: 5
    Last Post: 08-28-2017, 07:21 AM
  3. Replies: 1
    Last Post: 01-28-2015, 12:19 PM
  4. Finding last week
    By jgelpi16 in forum Queries
    Replies: 5
    Last Post: 09-21-2010, 02:32 PM
  5. Finding a weighted average
    By oldman in forum Queries
    Replies: 3
    Last Post: 09-10-2010, 08:41 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