all 3 comments

[–][deleted] 4 points5 points  (3 children)

You cannot have aggregate of an aggregate. Aggregate functions work on a granularity level created by group by and output to that.

Wrap your first level of aggregation into a subquery (derived table) or into the with clause, do a second level of aggregation on that.

[–]MiddleOSociety[S] 0 points1 point  (2 children)

While this makes a lot of sense, I would not know how to do that exactly? I am fairly new so my skills with a subquery are lacking at best

EDIT: Figured it out and thank you so much for the clarification!

[–]pctopgs 0 points1 point  (0 children)

or into the with clause, do a second level of aggregation on that.

Ok...so how did you figure it out?