The following example returns the largest integer equal to or less than 15.7:
SELECT FLOOR(15.7) "Floor" FROM DUAL;
Floor
----------
15
*******************************************************
The following example rounds a number to one decimal point:
SELECT ROUND(15.193,1) "Round" FROM DUAL; Round ---------- 15.2
The following example rounds a number one digit to the left of the decimal point:
SELECT ROUND(15.193,-1) "Round" FROM DUAL; Round ---------- 20
The following examples illustrate the difference between rounding NUMBER
and floating-point number values. NUMBER
values are rounded up (for positive values), whereas floating-point numbers are rounded toward the nearest even value:
SELECT ROUND(1.5), ROUND(2.5) FROM DUAL; ROUND(1.5) ROUND(2.5) ---------- ---------- 2 3 SELECT ROUND(1.5f), ROUND(2.5f) FROM DUAL; ROUND(1.5F) ROUND(2.5F) ----------- ----------- 2.0E+000 2.0E+000
*********************************************
The following examples truncate numbers:
SELECT TRUNC(15.79,1) "Truncate" FROM DUAL; Truncate ---------- 15.7
SELECT TRUNC(15.79,-1) "Truncate" FROM DUAL; Truncate ---------- 10
注:以上内容来自oracle 10g 帮助文档