解决方案 »

  1.   

    试一试这样可以不
    select case when time1 is not null and time2 is not null then time1||'到'||time2
                          when time1 is null and time2 is not null then '日期:'||time2
                          when time2 is null and time1 is not null then '日期:'||time1
                           else null end
    from 表名
      

  2.   


    with test as
     (select '1' time1, '2' time2
        from dual
      union all
      select '', '2'
        from dual
      union all
      select '1', ''
        from dual
      union all
      select '', '' from dual)
    select decode(time1, null, '', time1) ||
           (case
              when time1 is not null and time2 is not null then
               '到'
              else
               ''
            end) || decode(time2, null, '', time2)
      from test
      

  3.   


    恩,这个我有用过,就是没有想,简单的逻辑处理。3楼的逻辑看懂了,这算是方法还是存储过程?SQL写得少,比较菜
      

  4.   


    恩,这个我有用过,就是没有想,简单的逻辑处理。3楼的逻辑看懂了,这算是方法还是存储过程?SQL写得少,比较菜
    sql语句,因为在回答问题的时候我的建立临时表来获取一些数据,进行测试保证给你发的sql是准确的。使用了with as语句。
    你测试时候在测试窗口将我发的所有代码复制执行就能看出来效果了。
    你在看这种语句是,只关注with as后面跟的sql就行了。。具体with as用法,你可以上网查一下。。
      

  5.   


    恩,这个我有用过,就是没有想,简单的逻辑处理。3楼的逻辑看懂了,这算是方法还是存储过程?SQL写得少,比较菜
    sql语句,因为在回答问题的时候我的建立临时表来获取一些数据,进行测试保证给你发的sql是准确的。使用了with as语句。
    你测试时候在测试窗口将我发的所有代码复制执行就能看出来效果了。
    你在看这种语句是,只关注with as后面跟的sql就行了。。具体with as用法,你可以上网查一下。。看明白了,with as 的用法原来如此,后面的逻辑是正确的,也能实现我想要的效果,涨知识了