写一个sql语句,如果查询的某个值结果为空时给出提示。注意:不是存储过程

解决方案 »

  1.   

    select nvl(字段名,提示信息) 字段名
      

  2.   

    select decode(cloumn_name ,null,'没有数据,为空!!',cloumn) from table_name;
      

  3.   

    笔误  应该是
    select nvl(字段名,提示信息) from 表名
    当这个字段为null时返回提示信息 否则返回字段值
      

  4.   

    都对,甚至你还可以用case whenselect case when column is null then 'tips' else column end from table;
      

  5.   

    怎么个提示法?
    一般的nvl()函数就能实现
      

  6.   

    select nvl(字段名,提示信息) from 表名  这个后面能不能加条件?
    比如说select nvl(字段名,提示信息) from 表名 where ......
      

  7.   

    可以,没有影响
    nvl只是将原本那个字段会返回空值的部分,替换为后面的提示信息
      

  8.   

    比如
    select nvl(sid,'sid为空') from V$session where machine='test' 
    我这样写应该是对的啊,可是实际上不行啊
      

  9.   

    sid是数值型的吧
    后面的替换信息是字符串,类型不一致
    select nvl(to_char(sid),'sid为空') from ...
    再试试
      

  10.   

    不是类型的问题啊 现在扔这个错误java.sql.SQLException: ORA-00923: FROM keyword not found where expected
      

  11.   

    不好意思 发现了 我的from写错了 ,是可以成功的