如何在mysql查询中执行此操作

时间:2010-02-17 14:11:26

标签: mysql

我有一个mysql表,其中包含有关公司的数据:id, company name, city, address, telephone

我正在尝试编写一个查询,以获取其中有超过10家公司的城市列表。

有可能实现吗?

2 个答案:

答案 0 :(得分:2)

尝试

select city, count(*) as nbPerCity from tableName group by city having nbPerCity > 10;

答案 1 :(得分:2)

select city from Table group by city having count(company_name) > 10 ;

select s.city from 
   (select city,count(company_name) as counted from Table group by city) as s
where s.counted > 10