该任务是一个国家的名单,有超过10个客户我试图只显示的价值观,计数〉10在表中
我试过这个,但它没有过滤表:
select co.country, count(*) from sakila.country as co
inner join city as ci on co.country_id = ci.country_id
inner join address as ad on ci.city_id = ad.city_id
inner join customer as cu on cu.address_id = ad.address_id
group by co.country
order by count(*) > 10;
1条答案
按热度按时间2nbm6dog1#
通过只显示计数大于10的值,您需要使用
having
。having
需要使用,当你想过滤聚合函数的结果时,e.g.计数、求和。如果您仍然希望按计数排序结果,您仍然需要在en中设置
order by