HackerRank-My SQL
Prepare > SQL > Aggregation > Weather Observation Station 2
stem_sw
2023. 5. 17. 20:32
Weather Observation Station 2 | HackerRank
Write a query to print the sum of LAT_N and the sum of LONG_W separated by space, rounded to 2 decimal places.
www.hackerrank.com
문제
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.
=> LAT_N과 LONG_W 의 각 합을 반올림해 소숫점 이하 두 자리 까지 나타내라.
코드
SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W), 2) FROM STATION;
노트
ROUND( ~~, n)
ROUND([숫자], [소숫점자리])
- 소숫점 아래 n번째 자리까지 나타냄
두 번째 시도
SELECT ROUND(SUM(LAT_N),2), ROUND(SUM(LONG_W),2) FROM STATION;