select a.cc from a where a.bb='xxx'   cc,bb是a表的字段 数据库里没有这条记录  我想返回 0
怎么才可以做到

解决方案 »

  1.   

    select count(a.cc) cc from a where a.bb='xxx'
      

  2.   

    谢谢,但是如果有值的话得返回 a.cc
      

  3.   

    select nvl(a.cc,0) from a where a.bb='xxx'
      

  4.   

    也就是 select a.cc from a where a.bb='dd'  数据库里存在a.bb='dd'  a.cc='100' 时候 返回 100
      

  5.   

    nvl 不关用啊 nvl是对空值才可以  你在你的本地试试
      

  6.   

    刚才看错题目了,不好意思
    这类的问题只能用存储过程或者函数来实现吧,单纯用sql语句不太好返回的
      

  7.   

    select decode(b.rn,0,0,a.cc) as cc
    from(
    select a.cc from a where a.dd='xxx'
    ) a
    ,(select count(a.cc) rn from a where a.dd='xxx' ) b好像差不多,你试试看!