having 比较条件 后过滤放在group by后边
--- 统计中国,每个省的总人口大于1000w的省及人口数
SELECT district ,SUM(population) FROM city
WHERE countrycode='CHN'
GROUP BY district
HAVING SUM(population)>10000000
说明: having后的条件是不走索引的,可以进行一些优化手段处理。
having 比较条件 后过滤放在group by后边
--- 统计中国,每个省的总人口大于1000w的省及人口数
SELECT district ,SUM(population) FROM city
WHERE countrycode='CHN'
GROUP BY district
HAVING SUM(population)>10000000
说明: having后的条件是不走索引的,可以进行一些优化手段处理。