Null Functions
Null Functions
NVL(PCODE,323000)
-----------------
416502
416501
416608
416609
416508
416505
323000
416505
8 rows selected.
--nvl2 function
--used to replace not null and null values with some value
SQL> select nvl2(pcode,pcode,323000) from cust;
NVL2(PCODE,PCODE,323000)
------------------------
416502
416501
416608
416609
416508
416505
323000
416505
8 rows selected.
--nullif function
NULLIF(PCODE,PCODE)
-------------------
8 rows selected.
--nullif function
NULLIF(PCODE,123456)
--------------------
416502
416501
416608
416609
416508
416505
416505
8 rows selected.
--coalesce function
--it takes minimum 2 arguments and returns the first not null from the table
records.
9 rows selected.
COALESCE(PCODE,AGE)
-------------------
416502
416501
416608
416609
416508
416505
30
416505
25
9 rows selected.
COALESCE(AGE,PCODE)
-------------------
30
30
25
36
24
40
30
25
25
9 rows selected.