Monday, 29 May 2017

SQL Numeric Functions

SQL Numeric Function, sqrt(n),power(m,n),exp(n),mod(m,n),round(n,m),

trunc(n,m),ceil(n),floor(n) 


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;

1 comment:

  1. Thanks for the given information you are providing content very usefull to users.
    Learn How to Work With Ref Cursor in ORACLE 12C For Beginner Actual cost of this course is 9,999/- But now Kuncham Software Solutions Pvt ltd is giving you Free access. Limited period offer Hurry-up Enroll Now at Udemy.


    Hurry-Up Enroll Now and get Free Access to the Entire Course


    ReplyDelete

Cloning database with RMAN

Below are the steps to clone production database(primedb) to UAT database(clonedb)   STEP1 :- Check the both servers are able to connect ...