decode 好象是标准的sql-99,可以试试.
select decode(to_char(sysdate,'dd),'01',exp_1,'02',exp_2,'03',exp_3...exp_n) from table_1

解决方案 »

  1.   

    CASE是标准的sql-99, 我现在不能解决的是取Date类型的日期'DD'.
      

  2.   

    decode-->case
    to_char-->cast
      

  3.   

    cast 是可以进行数据类型转换,但我不知如何加入日期类型的格式.如'YYYY', 'MM', 'DD' 之类.
    select case cast(sysdate as date) -- 所得的是字符串'11-OCT-2003', 但我想行到'11' 
                   when '01' then exp_1
                   when '02' then exp_2
                   when '03' then exp_3
                   ...
                   else        exp_n
           end 
    from   table_1如何有CAST中加入格式码?
      

  4.   

    先 to_char() 再 decode()
      

  5.   

    to_char()是Oracle独有的,不属于标准SQL吧! 换句话说,我想上面的SQL在所有遵循SQL-99的database上都能运行,如DB2,SQLServer...都能得出正确结果.
    如果能将掩码加入到CAST函数中,我的问题就解决.但我查了些资料文档,没有发现在标准SQL实现类似功能:
      cast('12-OCT-2003 as date, format 'dd-mon-yyyy'), --指定格式String转成日期
      cast(sysdate as varchar2(2) format 'dd)           --指定日期转成特定格式字符
      

  6.   

    自已写函数,这样再利用oracle移值工具移值到其它数据库吧
      

  7.   

    先 to_char() 再 decode()