[MySQL] Hackerrank SQL 연습문제 (4)
less than 1 minute read
SQL Übung - Hackerrank
Japan Population
SELECT
SUM(POPULATION)
FROM
CITY
WHERE
COUNTRYCODE = 'JPN';
Population Density Difference
SELECT
MAX(POPULATION) - MIN(POPULATION)
FROM
CITY;
The Blunder
SELECT
CEIL(AVG(Salary) - AVG(REPLACE(Salary, 0, '')))
FROM
EMPLOYEES;
Top Earners
SELECT
months * salary,
COUNT(1)
FROM
Employee
GROUP BY
months * salary
ORDER BY
months * salary DESC
LIMIT
1;
Weather Observation Station 2
SELECT
ROUND(SUM(LAT_N), 2),
ROUND(SUM(LONG_W), 2)
FROM
STATION;
Weather Observation Station 13
SELECT
TRUNCATE(SUM(LAT_N), 4)
FROM
STATION
WHERE
LAT_N > 38.7880
AND LAT_N < 137.2345
Weather Observation Station 14
SELECT
TRUNCATE(MAX(LAT_N), 4)
FROM
STATION
WHERE
LAT_N < 137.2345
Weather Observation Station 15
SELECT
ROUND(LONG_W, 4)
FROM
STATION
WHERE
LAT_N < 137.2345
ORDER BY
LAT_N DESC
LIMIT 1;
Weather Observation Station 16
SELECT
ROUND(MIN(LAT_N), 4)
FROM
STATION
WHERE
LAT_N > 38.7780;
Weather Observation Station 17
SELECT
ROUND(LONG_W, 4)
FROM
STATION
WHERE
LAT_N > 38.7780
ORDER BY
LAT_N
LIMIT
1;