1) Weather Observation Station 3
1. 문제
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
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 id % 2 = 0
3. KEY POINT
- 짝수 표현 방법 : 1. n % 2 = 0
2. MOD(n, 2) = 0
www.hackerrank.com/challenges/weather-observation-station-3/problem?h_r=internal-search
2) Weather Observation Station 19
1. 문제
Consider P1(a, c) and P2(b, d) to be two points on a 2D plane where (a, b) are the respective minimum and maximum values of Northern Latitude (LAT_N) and (c, d) are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.
Query the Euclidean Distance between points and and format your answer to display decimal digits.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
[ 정의: Euclidean Distance ]
In the Euclidean plane, let point p have Cartesian coordinates (p1, p2) and let point q have coordinates (q1, q2).
Then the distance between p and q is given by
2. 답
SELECT ROUND(SQRT(POW(MIN(lat_n) - MAX(lat_n), 2) + POW(MIN(long_w) - MAX(long_w), 2)), 4)
FROM station
3. KEY POINT
- POW(컬럼명/값, n) : 값을 n 제곱해서 반환
- SQRT(컬럼명/값) : 값의 제곱근을 반환
www.hackerrank.com/challenges/weather-observation-station-19/problem?h_r=internal-search
'MySQL > 문제풀이' 카테고리의 다른 글
[HackerRank] Binary Tree Nodes (0) | 2021.03.23 |
---|---|
[HackerRank] Placements (0) | 2021.03.23 |
[HackerRank] Top Competitors (0) | 2021.03.23 |
[HackerRank] Population Density Difference / Weather Observation Station 11 / Weather Observation Station 13 (0) | 2021.03.23 |
[HackerRank] 여러 개의 INNER JOIN : New Companies (0) | 2021.03.22 |
댓글