Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002

    Unanswered: Query to Group by year

    I have a query that would have three files. One is a date field and I have a record for each day of the year. The other two are values. One I want to use as a criteria for the query and the other is a value for which I would like to get an average value for each year for about a twenty year period.

    I know I can run twenty queries each with a different year and run an aggregate avg function and then build another one with these to put togher a table of years with daily averages. This just seems very roundabout.

    I need a table that a query would produce as I want to export it to excel and combine it with other data for this time period for a chart.

    Is there a simple way to do this in a query or is there some simple code that will do this [I don't know coding]

    Thanks in advance

  2. #2
    Join Date
    Oct 2002
    Rochester, NY
    You could try creating a query that formats the date field as a year as a returned value. You would get one record for each year in your data table along with your query parameter and averaged value. All the work could be done in a single query.

    The date formatting would be accomplished using the DATEPART function:

    Hope it helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts