개인적인 정리

[Oracle]ROUND(number) 본문

DB/ORACLE

[Oracle]ROUND(number)

yeon.Biju 2020. 6. 10. 14:27

오라클 ROUND(number)

 

ROUND(number)

   - 

 

ROUND(n)

ROUND(n, integer)

의 형태

 

ROUND returns n rounded to integer places to the right of the decimal point. If you omit integer, then n is rounded to zero places. If integer is negative, then n is rounded off to the left of the decimal point. 

 

n can be any numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type. If you omit integer, then the function returns the value ROUND(n, 0) in the same data type as the numeric data type of n. If you include integer, then the function returns NUMBER.

 

ROUND is implement using the following rules:

   1. If n is 0, then ROUND always returns 0 regardless of integer.

   2. If n is negative, then ROUND(n, integer) returns -ROUND(-n, integer).

   3. If n is positve, then

ROUND(n, integer_ = FLOOR(n * POWER(10, integer) +0.5)* POWER(10, -integer)

 

ROUND applied to a NUMBER value any give a slightly different result from ROUND applied to the same value expressed in floating-point. The different results arise from differences in internal representations of NUMBER and floating point values. The difference will be 1 in the rounded digit if a difference occurs.

 

SQL> SELECT ROUND(15.193, 1) FROM DUAL ;

   --> 15.2

 

SQL> SELECT ROUND(15.193, -1) FROM DUAL ;

   --> 20

'DB > ORACLE' 카테고리의 다른 글

오라클 컬럼 이름 변경  (0) 2021.02.19
[Oracle]RTRIM()  (0) 2020.06.11
[Oracle]RPAD()  (0) 2020.06.11
[Oracle]ROW_NUMBER()  (0) 2020.06.11
[Oracle]ROUND(date)  (0) 2020.06.10
[Oracle]REPLACE()  (0) 2020.06.10
[Oracle]REMAINDER()  (0) 2020.06.10
[Oracle]REGEXP_SUBSTR()  (0) 2020.06.08
Comments