所以我有一个查询:
select states, count(numberofcounty)
from countytable
group by states
order by count(distinct numberofcounty) ASC;
它返回一个包含 2 列的表:从最少到最多的州数和县数。如何在单个实数中获得每个州有多少个县的平均值?
表结构为:
create table numberofcounty(
numberofcounty text,
states text references states(states),
);
create table states (
states text primary key,
name text,
admitted_to_union text
);