例如一个table,在库存为0时想要显示无库存,如何实现??

解决方案 »

  1.   


    SQL> 
    SQL> create table test(id int, kc int);
    Table created
    SQL> insert into test values(1,0);
    1 row inserted
    SQL> insert into test values(2,100);
    1 row inserted
    SQL> -- 使用 decode
    SQL> select id, decode(kc,0,'无库存',kc) kc from test;
                                         ID KC
    --------------------------------------- ----------------------------------------
                                          1 无库存
                                          2 100
    SQL> drop table test purge;
    Table droppedSQL> 
      

  2.   

    CASE 库存WHEN 0 THEN '无库存'  ELSE 库存 END 
      

  3.   

    oracle:
    select case kc when 0 then ‘无’
         when 1 then ‘有’
          end  kc
    from table;