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’。