[HackerRank|MySQL] Average Population / Japan Population / Population Density Difference

히끼·2020년 8월 22일
1

HackerRank

목록 보기
13/13

Average Population

Problem

Query the average population for all cities in CITY, rounded down to the nearest integer.

Solution

SELECT FLOOR(AVG(POPULATION))
FROM CITY

Japan Population

Problem

Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.

Solution

SELECT SUM(POPULATION)
FROM CITY
WHERE COUNTRYCODE = 'JPN'

Population Density Difference

Problem

Query the difference between the maximum and minimum populations in CITY.

Solution

SELECT MAX(POPULATION) - MIN(POPULATION)
FROM CITY

0개의 댓글