Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How to average the results of four queries in SQL

$
0
0

This is a continuation of two separate questions.

https://community.spiceworks.com/topic/2169128-anomalous-sql-query-results?page=1#entry-8021421

https://community.spiceworks.com/topic/2168749-having-sql-return-nonexistent-values-part-iii?page=1#...

The report that the query results would go into used to have four quarters. Each area, indcode combination would be represented four times. However, now they want it to collapsed into one and therefore averaged together. I could put the four results in excel and then average it. However, looking to avoid Excel. To average the results, would it simply be the following code at the beginning with some modifications or is it more involved than that?

The second query below is one that returns exactly what is needed for each quarter.

NOTE: Not sure why second code snippet is behaving strange.

Text
...

Viewing all articles
Browse latest Browse all 4871

Trending Articles