ROUND 함수

설명

ROUND 함수는 지정된 인자 number_operand를 소수점 아래 integer 자리까지 반올림한 값을 반환한다. 반올림할 자릿수를 지정하는 integer 인자가 생략되거나 0인 경우에는 소수점 아래 첫째 자리에서 반올림한다. 그리고 integer 인자가 음수이면, 소수점 위 자리, 즉 정수부에서 반올림한다.

구문

ROUND( number_operand, integer )

예제

--it rounds a number to one decimal point when the second argument is omitted

SELECT ROUND(34567.34567), ROUND(-34567.34567);

  round(34567.34567, 0)   round(-34567.34567, 0)

============================================

  34567.00000           -34567.00000

 

 

--it rounds a number to three decimal point

SELECT ROUND(34567.34567, 3), ROUND(-34567.34567, 3)  FROM db_root;

 round(34567.34567, 3)   round(-34567.34567, 3)

============================================

  34567.34600           -34567.34600

 

--it rounds a number three digit to the left of the decimal point

SELECT ROUND(34567.34567, -3), ROUND(-34567.34567, -3);

 round(34567.34567, -3)   round(-34567.34567, -3)

============================================

  35000.00000           -35000.00000