SQuirreL
SQuirreL

Reputation: 129

Report Builder Total of Grouped Averages

how can I summarize group average in a table I have earlier created. I don't want have the averages of the whole table.

1          A       10
2          B       20 
3          B       15
4          A       20
5          B       10
By Group   A       15
           B       11.67 
Total              16.67

Help would be much appreciated

Upvotes: 1

Views: 1143

Answers (1)

Yang
Yang

Reputation: 8170

Assume table T has following schema:

id         name     num
1          A        10
2          B        20 
3          B        15
4          A        20
5          B        10
By Group   A        15
           B        15   -- <= Note: this should be 15.
Total               30

Then, you can use

SELECT SUM(a) FROM (
  SELECT AVG(num) AS a
  FROM T
  GROUP BY name
) AS gavg;

Check out the demo here. Let me know if it works for you.

Upvotes: 1

Related Questions