Numeric function (learning notes), numeric function learning notes
-- ************************************ Digital functions
-- ABS: returns the absolute value.
SELECT ABS(3),ABS(-100) FROM dual;
Result: 3,100
-- CEIL rounded up
SELECT CEIL(3.34343),CEIL(3.932),CEIL(-3.4432),CEIL(-5.9889) FROM dual;
Result: 4,4,-3,-5.
-- Floor rounded down
SELECT FLOOR(3.34343),FLOOR(3.932),FLOOR(-3.4432),FLOOR(-5.9889) FROM dual;
Result: 3, 3,-4,-6.
-- Sin --- cosine
SELECT SIN(4),COS(4) FROM dual;
-- Power function power (m, n), n power of m
SELECT POWER(2,4) FROM dual;
Result: 16
-- Round
-- Verify the use of the round Function
Select round (785.652) does not retain decimal places, ROUND (785.652, 2) retains two decimal places, ROUND (785.652,-1) returns one integer, ROUND (785.352) the first digit of the decimal place is less than 5 rounded off, and the rounded digit (784.652,-1) is less than 5 rounded off FROM dual;
Result: 786,785.65, 790,785,780
-- List the basic information and daily salary of each employee. The daily salary is only kept at 2 decimal places, 30 days per month.
SELECT e. empno, e. ename, e. sal, round (e. sal/30, 2) daily salary FROM emp e;
-- Verify that the TRUNC function intercepts uncarried
Select trunc (785.652) does not retain decimal places, TRUNC (785.652, 2) retains two decimal places, TRUNC (785.652,-1) returns one integer, TRUNC (785.352) if the decimal number is retained, TRUNC (784.652,-1) rounds the entire number into a single digit FROM dual;
Result: 785,785.65, 780,785,780
-- Verify MOD for the remainder Function
SELECT MOD(10,3)FROM dual;
Result: 1
-- Square root sqrt
SELECT SQRT(16) FROM dual;
Result: 4