What is this CASE statement doing exactly with the NVL function? case when nvl(Q_IND, 0) = 1 then 1 else 0 end Q_IND


I'm having a hard time understanding what is happening in the above statement. Could someone explain?
From the documentation:


  NVL lets you replace null (returned as a blank) with a string in the results of a query. If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returns expr1.


So for your specific example, if Q_IND is NULL then 0 is returned to the CASE statement. For such scenarios your CASE statement becomes this:

CASE WHEN 0 = 1 THEN 1 ELSE 0 END Q_IND


We all know that 0 is not equal to 1 and thus 0 is returned as Q_IND.