1) Population Density Difference
1. 문제
Query the difference between the maximum and minimum populations inCITY.
Input Format
The CITY table is described as follows:
2. 답
SELECT MAX(population) - MIN(population)
FROM city
3. KEY POINT
- MAX(컬럼명) : 해당 컬럼에서의 최댓값
- MIN(컬럼명) : 해당 컬럼에서의 최솟값
www.hackerrank.com/challenges/population-density-difference/problem?h_r=internal-search
2) Weather Observation Station 11
1. 문제
Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
2. 답
SELECT DISTINCT(city)
FROM station
WHERE LEFT(city, 1) NOT IN ('A', 'E', 'I', 'O', 'U')
OR RIGHT(city, 1) NOT IN ('A', 'E', 'I', 'O', 'U')
3. KEY POINT
- LEFT(컬럼명, n) : 해당 컬럼의 문자열 중에 왼쪽부터 n번째 글자 추출
- RIGHT(컬럼명, n) : 해당 컬럼의 문자열 중에 오른쪽부터 n번째 글자 추출
- 컬럼명 IN (값) : 해당 컬럼 안에 특정 값들이 들어있는 글자 추출
www.hackerrank.com/challenges/weather-observation-station-11/problem?h_r=internal-search
3) Weather Observation Station 13
1. 문제
Query the sum of Northern Latitudes (LAT_N) from STATION having values greater than 38.7880 and less than 137.2345. Truncate your answer to 4 decimal places.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
2. 답
SELECT TRUNCATE(SUM(lat_n), 4)
FROM station
WHERE lat_n > 38.7880 AND lat_n < 137.2345
3. KEY POINT
- TRUNCATE(컬럼명/값, n) : 값을 소수점 이하 n자릿수까지만 남기고 나머지 버림
www.hackerrank.com/challenges/weather-observation-station-13/problem?h_r=internal-search
'MySQL > 문제풀이' 카테고리의 다른 글
[HackerRank] Weather Observation Station 3 / Weather Observation Station 19 (0) | 2021.03.23 |
---|---|
[HackerRank] Top Competitors (0) | 2021.03.23 |
[HackerRank] 여러 개의 INNER JOIN : New Companies (0) | 2021.03.22 |
[HackerRank] Japan Population / Weather Observation Station 2 / Weather Observation Station 18 (0) | 2021.03.22 |
[LeetCode] 175. Combine Two Tables (0) | 2021.03.22 |
댓글