1 如果某字段是空值,则返回一个默认值
Oracle中:nvl(arg,value)
DB2中:coalesce(arg,value)或value(arg,value)
Sql Server中:ISNULL(arg,value)
2 多条件判断
仅有oracle提供了decode函数:decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)
示例如下:
select decode( x , 1 , ‘x is 1 ’, 2 , ‘x is 2 ’, ‘others’) from dual
当x等于1时,则返回‘x is 1’。
当x等于2时,则返回‘x is 2’。
否则,返回others’。