开发者

How to do this in a mysql query

开发者 https://www.devze.com 2022-12-20 05:39 出处:网络
I have got a mysql table containing data about companies: id, company name, city, address, telephone.

I have got a mysql table containing data about companies: id, company name, city, address, telephone.

I'm trying to write a quer开发者_高级运维y for getting list of cities where there are more then 10 companies within.

Is it possible to achieve that?


Try

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


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

or

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号