SQL. Table with quarterly averages based on monthly data

0

I have a table with monthly numeric data fields (January to December) for several years. I want to generate a new table that contains the quarterly averages for those numeric fields for each year, so that the generated table should look like this:

" Year " " Quarter " " Average Field1 " " Average Field2 " " Average CampoN "

I have limited experience with the SELECT, SELECT INTO and UPDATE commands, but I do not see how I can produce that result.

Additional clarification: My table covers monthly information for several years, so it looks like this:

Year Month Field1 Field2 FieldN 2015 1 100 200 300 2015 ................................... (months 2 to 11) 2015 12 130 225 315 2016 1 135 215 295 2016 ................................... (months 2 to 11) 2017 1 140 250 320 2017 ................................... (months 2 to 11) 2018 1 160 270 340 2017 ................................... (months 2 to 7) 2018 8 170 275 350

I intend to obtain quarterly averages, that is, the average of January-March, April-June, July-September and October-December of each year.

I do not see how I can get all this information in a single query.

Thank you.

    
asked by Mario Collado 27.09.2018 в 16:46
source

1 answer

0

The syntax is this to find the average is this:

SELECT AVG(column_name)
FROM table_name
WHERE condition;

Adjust it to your columns and tell us if it worked.

    
answered by 28.09.2018 в 12:11