1

在 sql 中,您可以将 GROUP BY 函数与国家之类的列一起使用吗?(这将是一个 char/varchar)

SELECT country, population, COUNT(*) AS count_cities
FROM list_of_cities
GROUP BY country;

写这个更好的方法是什么?

4

1 回答 1

3
SELECT country, SUM(population) AS country_population, COUNT(*) AS count_cities 
FROM list_of_cities 
GROUP BY country;
于 2013-01-12T01:30:22.713 回答