Oracle Optimization Study Notes 01---Converting Null Values to Actual Values

Oracle null values ​​are converted into actual values. The first reaction is to use nvl. However, there is another function that can be used: coalesce(col1,col2,col3,....), coalesce supports multiple parameters and can easily return the first A non-null value.
select  coalesce(col1,col2,col3,col4) from dual 
Description: When col1 is empty, the value is col2, when col2 is empty, the value is col3, and when col3 is empty, the value is col4
Equivalent to
select nvl(nvl(nvl(col1,col2),col3),col4) from dual

The following table:

select  coalesce(c1,c2,c3,c4) from mh ;

The result is as follows:




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324686756&siteId=291194637