2021. 1. 5. 22:40ㆍToday I Learned.../MySQL
Weather Observation Station 2
Query the following two values from the STATION table:
- The sum of all values in LAT_N rounded to a scale of 2 decimal places.
- The sum of all values in LONG_W rounded to a scale of 2 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.
Output Format
Your results must be in the form:
lat lon
where lat is the sum of all values in LAT_N and lon is the sum of all values in LONG_W. Both results must be rounded to a scale of 2 decimal places.
select round(sum(lat_n), 2), round(sum(long_w), 2)
from station
Weather Observation Station 13
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.
select truncate(sum(lat_n), 4)
from station
where lat_n > 38.7880 and lat_n < 137.2345
ROUND(숫자, 자릿수) | 자릿수 + 1 에서 반올림 |
TRUNCATE(숫자, 자릿수) | 자릿수 아래로 버림 |
Weather Observation Station 14
Query the greatest value of the Northern Latitudes (LAT_N) from STATION that is less than 137.2345. Truncate your answer to 4 decimal places.
select truncate(max(lat_n), 4)
from station
where lat_n < 137.2345
Weather Observation Station 15
Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345. Round your answer to 4 decimal places.
select round(long_w, 4)
from station
where lat_n < 137.2345
order by lat_n desc
limit 1
Weather Observation Station 16
Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780. Round your answer to 4 decimal places.
select round(min(lat_n), 4)
from station
where lat_n > 38.7780
Weather Observation Station 17
Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780. Round your answer to 4 decimal places.
select round(long_w, 4)
from station
where lat_n = (select min(lat_n) from station where lat_n > 38.7780)
문제출처: 해커랭크
'Today I Learned... > MySQL' 카테고리의 다른 글
[HackerRank MySQL] Draw The Triangle 1 & 2 - information_schema.tables (0) | 2021.01.05 |
---|---|
[HackerRank MySQL] INNER JOIN 문제풀기 (Basic) (0) | 2021.01.05 |
[HackerRank MySQL] Count/Sum/Average, Ceil/Floor, Replace 문제풀기 (Basic) (0) | 2021.01.05 |
[HackerRank MySQL] ORDER BY 문제풀기 (Basic) (0) | 2021.01.05 |
[HackerRank MySQL] Weather Observation Station 1, 3-12 + REGEXP (Basic) & MOD() Function (0) | 2021.01.05 |