大家好
有一个表(tb_a),其中有一列(id)
请问如何写SELECT语句来实现当id=0显示9,当id=1时显示8.其余不变
谢谢!

解决方案 »

  1.   

    select decode(id,0,9,1,8,id) from tb_a;
      

  2.   

    毫无疑问在ORACLE下,肯定是使用DECODE函数的。
      

  3.   

    select decode(id,'0','9','1','8',id) id from tb_a;
      

  4.   


    DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )
      

  5.   

    select (case when id=0 then 9
                 when id=1 then 8
                 else id end ) id from tb_a;