【发布时间】:2014-03-26 21:07:00
【问题描述】:
我有一个名为 studios 的表,其中包含“earnings”和“country”列。该表的每一项都描述了一个国家的工作室及其收入。
如何选择每个国家/地区工作室的平均收入?
SELECT AVG(earnings) --I want per country
FROM studios
【问题讨论】:
我有一个名为 studios 的表,其中包含“earnings”和“country”列。该表的每一项都描述了一个国家的工作室及其收入。
如何选择每个国家/地区工作室的平均收入?
SELECT AVG(earnings) --I want per country
FROM studios
【问题讨论】:
SELECT country,AVG(earnings) FROM studios GROUP BY country;
【讨论】:
你可以这样做:"SELECT AVG(earnings) FROM studios GROUP BY country"
如果你有列 country_id 是首选。
你可以使用这个查询"SELECT AVG(earnings),country FROM studios GROUP BY country"
【讨论】:
你可以用这个:
SELECT AVG(earnings) , country from studios group by country
【讨论】: