[MYSQL] Weather Observation Station 2
▶ SQL > Aggregation > Weather Observation Station 2
Problem
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.
→ LAT_N의 모든 값의 합을 소수점 2자리까지 반올림한 값 - The sum of all values in LONG_W rounded to a scale of 2 decimal places.
→ LONG_W의 모든 값의 합을 소수점 2잘까지 반올림한 값
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.
My Answer
SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W), 2)
FROM STATION
NOTE
반올림을 하는 함수 ROUND()와 합을 구하는 함수 SUM()을 사용하면 해결되는 문제이다!
MYSQL의 숫자 함수는 아래 포스팅에 정리되어 있으니 참고!
[MYSQL] The Blunder
SQL > Aggregation > The Blunder Problem Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 0 key was b..
junyoung-developer.tistory.com