SQL Numeric Functions

Numeric Functions

SQL Functions:-Oracle has provided a lot of functions that are divided in below sub-category
            A) Single row functions   
                1) Numeric Functions
                2) String Functions
                3) Date Functions
                4) Conversion Functions
            B) Multi row/Group/Grouping function
              
Nemeric function:-Below are the listed function under Numeric Functions category.
sqrt(n),power(m,n),exp(n),mod(m,n),round(n,m),trunc(n,m),ceil(n),floor(n)

Examples:-
select sqrt(144) from dual;
select ename,sqrt(sal) from emp;

select power(3,4) from dual;
select ename,power(sal,2) from emp;

select exp(3) from dual;--exponential e*e*e (e=2.718)

select mod(17,3) from dual;
select ename,mod(sal,2) from emp;

select round(12.345678,2) from dual;
select empno,ename,round(sal,2) from emp;

select trunc(12.34567,2) from dual;
select ename,trunc(sqrt(sal),4) from emp;


select floor(12.345678) from dual;
select ceil(12.345678) from dual;

Some more Examples :-
SELECT 2*6 FROM DUAL;
SELECT 2*(13-9) FROM DUAL;
SELECT TRUNC(13.2365,2) FROM DUAL;
SELECT ROUND(13.2365,2) FROM DUAL;
SELECT AVG(SAL) FROM EMP;
SELECT ROUND(AVG(SAL),3) FROM EMP;
SELECT CEIL(13.5674) FROM DUAL;
SELECT FLOOR(13.5674) FROM DUAL;
SELECT FLOOR(AVG(SAL)) FROM EMP;
SELECT POWER(3,4) FROM DUAL;
SELECT SQRT(81) FROM DUAL;
SELECT EMPNO,ENAME,JOB,SAL,NVL(COMM,100) FROM EMP;
SELECT SAL+NVL(COMM,0) FROM EMP;

No comments:

Post a Comment