NVL function in Oracle return default value if there is NULL value in the first expression.
Syntax:-
NVL(EXPRESSION,'DEFAULT_VALUE);
Example:-
SELECT EMPNO,NVL(EMPNAME,'CHANCHAL') AS EMPNAME,NVL(SALARY,9000) AS SALARY
FROM EMPLOYEE
WHERE EMPNO=7;
SQL> SELECT * FROM EMPLOYEE;
EMPNO EMPNAME SALARY DEPTNO
---------- -------------------- ---------- ----------
1 CHANCHAL 1000 10
2 WANKHADE 2000 20
3 SCOTT 3000 200
4 TIGER 4000 200
5 JOHN 5000 300
6 JAKE 6000 300
7
7 rows selected.
SQL> SELECT EMPNO,NVL(EMPNAME,'CHANCHAL') AS EMPNAME,NVL(SALARY,9000) AS SALARY
2 FROM EMPLOYEE
3 WHERE EMPNO=7;
EMPNO EMPNAME SALARY
---------- -------------------- ----------
7 CHANCHAL 9000
Read Also:- ISNULL function in SQL
Syntax:-
NVL(EXPRESSION,'DEFAULT_VALUE);
Example:-
SELECT EMPNO,NVL(EMPNAME,'CHANCHAL') AS EMPNAME,NVL(SALARY,9000) AS SALARY
FROM EMPLOYEE
WHERE EMPNO=7;
SQL> SELECT * FROM EMPLOYEE;
EMPNO EMPNAME SALARY DEPTNO
---------- -------------------- ---------- ----------
1 CHANCHAL 1000 10
2 WANKHADE 2000 20
3 SCOTT 3000 200
4 TIGER 4000 200
5 JOHN 5000 300
6 JAKE 6000 300
7
7 rows selected.
SQL> SELECT EMPNO,NVL(EMPNAME,'CHANCHAL') AS EMPNAME,NVL(SALARY,9000) AS SALARY
2 FROM EMPLOYEE
3 WHERE EMPNO=7;
EMPNO EMPNAME SALARY
---------- -------------------- ----------
7 CHANCHAL 9000
Read Also:- ISNULL function in SQL
No comments:
Post a Comment