filmov
tv
NVL Function in oracle with example||How to handle null values||Oracle sql plsql tutorial
Показать описание
NVL Function in oracle with example||How to handle null values||Oracle sql plsql tutorial
It is said to be the SQL general function which checks the first input parameter value,
if the first input parameter value is null then it will return the second input parameter value as output.
NVL(expr1,expr2):It converts the null value to the actual value. Expr1 and Expr2 is having the same data type.
If the expr1 which is having the source value as null then it will be replaced by the second argument and called as target value.
It converts the null value to the not null value, if the second expression is not null. It accepts the data type like character, number,date and time
It will hold the two input values and if we try to provide more than two input values, it will provide you an error.
This function will be returning the first not null value in the search expression.
SELECT NVL('A','B') AS OUTPUT FROM DUAL;
SELECT NVL(A,2.67) AS OUTPUT FROM DUAL;
SELECT NVL(NULL,'C') AS OUTPUT FROM DUAL;
SELECT NVL('NULL','NULL') AS OUTPUT FROM DUAL;
SELECT NVL(NULL,NULL) AS OUTPUT FROM DUAL;
SELECT NVL(2,3) AS OUTPUT from dual;
SELECT NVL(NULL,4) AS OUTPUT from dual;
SELECT NVL(2.56,6.78) AS OUTPUT from dual;
SELECT NVL(NULL,6.78) AS OUTPUT from dual;
SELECT NVL(10,20,30) AS OUTPUT FROM DUAL;
select * from emp;
select sal,nvl(comm,0),(sal*12)+(sal*12*NVL(COMM,0))annual_salary from emp;
SELECT ENAME,SAL,NVL(COMM,0),(SAL)+(SAL*NVL(COMM,0)) MONTHLY_SALARY FROM EMP;
It is said to be the SQL general function which checks the first input parameter value,
if the first input parameter value is null then it will return the second input parameter value as output.
NVL(expr1,expr2):It converts the null value to the actual value. Expr1 and Expr2 is having the same data type.
If the expr1 which is having the source value as null then it will be replaced by the second argument and called as target value.
It converts the null value to the not null value, if the second expression is not null. It accepts the data type like character, number,date and time
It will hold the two input values and if we try to provide more than two input values, it will provide you an error.
This function will be returning the first not null value in the search expression.
SELECT NVL('A','B') AS OUTPUT FROM DUAL;
SELECT NVL(A,2.67) AS OUTPUT FROM DUAL;
SELECT NVL(NULL,'C') AS OUTPUT FROM DUAL;
SELECT NVL('NULL','NULL') AS OUTPUT FROM DUAL;
SELECT NVL(NULL,NULL) AS OUTPUT FROM DUAL;
SELECT NVL(2,3) AS OUTPUT from dual;
SELECT NVL(NULL,4) AS OUTPUT from dual;
SELECT NVL(2.56,6.78) AS OUTPUT from dual;
SELECT NVL(NULL,6.78) AS OUTPUT from dual;
SELECT NVL(10,20,30) AS OUTPUT FROM DUAL;
select * from emp;
select sal,nvl(comm,0),(sal*12)+(sal*12*NVL(COMM,0))annual_salary from emp;
SELECT ENAME,SAL,NVL(COMM,0),(SAL)+(SAL*NVL(COMM,0)) MONTHLY_SALARY FROM EMP;