Posts

Showing posts from February, 2015

NULLIF, NVL, NVL2, COALESCE Functions

create table hr . dummy (id number , name varchar2 ( 32 ), bdate date ) tablespace users; insert into hr . dummy (id,name, bdate ) values ( 3 , 'Carl' ,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 7 , 'Gary' ,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 2 ,NULL,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 6 ,NULL,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 1 , 'Anna' , SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 5 , 'Fitzgerald' ,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 4 ,NULL,SYSDATE); insert into hr . dummy (id,name, bdate ) values ( 0 ,NULL,SYSDATE); commit; NVL2  lets you determine the value returned by a query based on whether a specified expression is null or not null NVL just return something whether expression is NULL. SELECT NAME, NVL2(NAME, 'Registered' , 'Pen