문제

I have a table named studios with the columns "earnings" and "country". Each item of that table describes a studio in a country and its earnings.
How can I select the average earnings of the studios for each country?

SELECT AVG(earnings) --I want per country
FROM studios
도움이 되었습니까?

해결책

SELECT country,AVG(earnings) FROM studios GROUP BY country;

다른 팁

You can do that: "SELECT AVG(earnings) FROM studios GROUP BY country" If you have column country_id is for prefer.

You can use and this query "SELECT AVG(earnings),country FROM studios GROUP BY country"

You can use this:

SELECT AVG(earnings) , country from studios group by country
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top