round--四舍五入函数
trunc--截断函数
mod--求余函数
round和trunc除了可以操作数字外还可以操作日期。
Demo
1 SQL> select round(45.926,2),round(45.926,1),round(45.926,0),round(45.926),round(45.926,-1),round(45.926,-2) 2 2 from dual 3 3 ; 4 5 ROUND(45.926,2) ROUND(45.926,1) ROUND(45.926,0) ROUND(45.926) ROUND(45.926,-1) ROUND(45.926,-2) 6 --------------- --------------- --------------- ------------- ---------------- ---------------- 7 45.93 45.9 46 46 50 0 8 9 10 SQL> select trunc(45.926,2),trunc(45.926,1),trunc(45.926,0),trunc(45.926),trunc(45.926,-1),trunc(45.926,-2) 11 2 from dual; 12 13 TRUNC(45.926,2) TRUNC(45.926,1) TRUNC(45.926,0) TRUNC(45.926) TRUNC(45.926,-1) TRUNC(45.926,-2) 14 --------------- --------------- --------------- ------------- ---------------- ---------------- 15 45.92 45.9 45 45 40 0 16 17 SQL> select mod(15,4) from dual; 18 19 MOD(15,4) 20 ---------- 21 3
时间: 2024-12-26 09:12:50