Reputation: 69
select avg(select count(aid)
from athlete
group by codepays)
I get a "more than one row error". How with I go about getting the average of the result from my fist select ?
Upvotes: 0
Views: 212
Reputation: 48770
You need to use a table expression (subquery).
For example:
select avg(cnt)
from (
select count(aid) as cnt
from athlete
group by codepays
) x
Upvotes: 1
Reputation: 1269503
You can do this using division:
select count(aid) / count(distinct codepay)
from athlete;
No subqueries are necessary.
(Although the arithmetic needs to be tweaked if codepay
can actually be NULL
.)
Upvotes: 0