ISNULL function in SQL return default value if there is NULL value in the first expression.
Syntax:-
ISNULL (EXPRESSION,'DEFAULT_VALUE');
EXAMPLE:-
SELECT * FROM EMPLOYEE;
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 null null null
SELECT EMPNO,ISNULL(EMPNAME,'SCOTT') AS EMPNAME,ISNULL(SALARY,10000) SALARY
FROM EMPLOYEE
WHERE EMPNO=7;
EMPNO EMPNAME SALARY
---------- -------------------- ----------
7 SCOTT 10000
SELECT ISNULL(NULL,'CHANCHAL WANKHADE');
--> CHANCHAL WANKHADE
SELECT ISNULL('CHANCHAL','WANKHADE');
--> CHANCHAL
We can use it to handle the date as well.
SELECT ISNULL(NULL, '2010-01-01');
--> '2010-01-01'
Read Also:- NVL function in Oracle
Syntax:-
ISNULL (EXPRESSION,'DEFAULT_VALUE');
EXAMPLE:-
SELECT * FROM EMPLOYEE;
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 null null null
SELECT EMPNO,ISNULL(EMPNAME,'SCOTT') AS EMPNAME,ISNULL(SALARY,10000) SALARY
FROM EMPLOYEE
WHERE EMPNO=7;
EMPNO EMPNAME SALARY
---------- -------------------- ----------
7 SCOTT 10000
SELECT ISNULL(NULL,'CHANCHAL WANKHADE');
--> CHANCHAL WANKHADE
SELECT ISNULL('CHANCHAL','WANKHADE');
--> CHANCHAL
We can use it to handle the date as well.
SELECT ISNULL(NULL, '2010-01-01');
--> '2010-01-01'
Read Also:- NVL function in Oracle
No comments:
Post a Comment