Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

forest_moon

[hackerrank, SQL] Weather Observation Station 2 본문

알고리즘

[hackerrank, SQL] Weather Observation Station 2

rokga 2022. 12. 30. 15:32

위도 경도의 총합

Query the following two values from the STATION table:

  1. The sum of all values in LAT_N rounded to a scale of  decimal places.
  2. The sum of all values in LONG_W rounded to a scale of  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  is the sum of all values in LAT_N and  is the sum of all values in LONG_W. Both results must be rounded to a scale of  decimal places.

 

SELECT
ROUND(SUM(lat_n), 2),
ROUND(SUM(long_w), 2)
FROM
station
;

 

 

 

ROUND는 지정한 자리에서 반올림하는 함수입니다

오라클 SQL에서 소수점 자리수를 지정하기 위해서 ROUND 함수를 사용한다. ROUND 함수는 특정 소수점을 반올림하고 나머지를 버리는 함수 이다.

 

*** 반대로 소수점을 반올림하지 않고 절사만 원한다면 TRUNC 함수를 사용해야 한다.