Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张cities包含以下信息的表格:
cities
name, country, population, capital, shape
我需要获得两个特定国家(阿根廷和墨西哥)中每个城市的人口平均值,而不是将它们加在一起。
有没有办法同时进行两个平均查询?
我只是想知道这是否可以或不能完成。
您应该能够GROUP BY在城市和国家/地区使用类似的东西:
GROUP BY
select city, country, avg(population) AvgPop from yourtable where country in ('Argentina', 'Mexico') group by city, country