oracle中nvl函数用法

1.返回两个字段中非空字段的值,第一个字段非空,返回第一个字段的值,第二个字段值为null,则返回第二个字段的值,如果都为null 则返回null。

  select nvl(a,b) from table1 where .....

  其中a,b均为table1中字段,

  如果a为null,则取得b的值。

2.返回两个表达式中计算结果非空的值。

  select nvl( expression1 , expression2 ) from table1 where ......

  其中expression1,expression2均为表达式,如sum(),结果返回计算结果不为null的值。如果都是null,那就返回null。

3.巧妙用法。

  select nvl(a.name,"空的") as name from student a where ......

  当a.name为空的时候,返回的界面为“空的”,看着比较直观。

posted on 2013-08-01 16:23  Mr.SuYang  阅读(2120)  评论(0)    收藏  举报

导航