TRUNC 함수와 TRUNCATE 함수는 지정된 인자 x의 소수점 아래 숫자가 dec 자리까지 표현되도록 버림(trunctation)한 값을 반환한다. 단, TRUNC 함수의 dec 인자는 생략할 수 있지만, TRUNCATE 함수의 dec 인자는 생략할 수 없다. 버림할 위치를 지정하는 dec 인자가 음수이면 정수부의 소수점 위 dec 번째 자리까지 0으로 표시한다. 리턴 값의 표현 자릿수는 인자 x를 따른다.
TRUNC( x[, dec] )
TRUNCATE( x, dec )
--it returns a number truncated to 0 places
SELECT TRUNC(34567.34567), TRUNCATE(34567.34567, 0);
============================================
34567.00000 34567.00000
--it returns a number truncated to three decimal places
SELECT TRUNC(34567.34567, 3), TRUNC(-34567.34567, 3);
============================================
34567.34500 -34567.34500
--it returns a number truncated to three digits left of the decimal point
SELECT TRUNC(34567.34567, -3), TRUNC(-34567.34567, -3);
============================================
34000.00000 -34000.00000