【发布时间】:2013-10-13 22:25:50
【问题描述】:
所以我有疑问:
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
);
【问题讨论】:
-
你能发布你的表结构吗?
-
每个州有多少个国家?不是每个国家有多少个州吗?