The following content mainly introduces the practical application of the ceil function in Oracle Database to evaluate the smallest integer greater than a certain number, the following is a detailed description of the actual operations. I hope you will gain some benefits after browsing the following content.
- SQL> select ceil(comm),comm from myemp where ename='MORFLAME';
- CEIL(COMM) COMM
- 556 555.55
Floor function: returns the maximum integer smaller than a certain number.
- SQL> select floor(comm),comm from myemp where ename='MORFLAME';
- FLOOR(COMM) COMM
- 555 555.55
Mod
- SQL> select mod(12,3) from dual
The dual table here is a virtual table that is only used to test functions.
MOD (12, 3)
0
Abs, returns the absolute value function.
- SQL> select abs(-3) from dual;
- ABS(-3)
3
Other mathematical Oracle database functions include cos, cosh, exp, ln, log, sin, sinh, sqrt, tan, tanh, acos, asin, atan ......
Date Functions
Sysdate: returns the system time.
- select sysdate from dual;
Add_months (d, n): add the date of n months from the date d.
Ask the employees who joined the company 8 months ago:
- select * from myemp where sysdate>add_months(hiredate,8);
Days of employment:
Select sysdate-hiredate "days of employment", ename from myemp;
Employment days ENAME
10644.4805 SMITH
10579.4805 ALLEN
8073.48059 MORFLAME
Last_day (d): returns the last day of the month of the specified date.
Ask the employees who joined the company on the last three days of this month:
- select ename,hiredate from emp where l
ast_day(hiredate)-2=hiredate;
The above content is an introduction to the relevant functions in the Oracle database. I hope you will get some benefits.