I have column "Country" in "Address" table.
我在“地址”表中有“国家/地区”列。
I want to return only data for those countries that have 10 rows.
我想只返回那些有10行的国家/地区的数据。
For example, if France has 10 rows (and other countries) I want to see them. If I have Italy with only 9 records I don't want to see it.
例如,如果法国有10行(和其他国家/地区),我想看到它们。如果我的意大利只有9条记录,我不想看到它。
Thank you!
1 个解决方案
#1
2
Create one group per country, and then demand that the group has 10 rows:
每个国家/地区创建一个组,然后要求该组有10行:
select Country
from Address
group by
Country
having count(*) = 10
To return all rows with those countries, you can use a subquery:
要返回包含这些国家/地区的所有行,您可以使用子查询:
select *
from Address
where Country in
(
select Country
from Address
group by
Country
having count(*) = 10
)
#1
2
Create one group per country, and then demand that the group has 10 rows:
每个国家/地区创建一个组,然后要求该组有10行:
select Country
from Address
group by
Country
having count(*) = 10
To return all rows with those countries, you can use a subquery:
要返回包含这些国家/地区的所有行,您可以使用子查询:
select *
from Address
where Country in
(
select Country
from Address
group by
Country
having count(*) = 10
)