比如:decode(TIME,'<120','2-','120<??<300','3-5')
就是我想根据TIME的值来换,不可能从1-120,120-300都让我写一个吧?能用范围找吗?

解决方案 »

  1.   

    不行。用case吧。
    case的性能与decode相当,10g略高于decode,而且比decode直观,易与维护
      

  2.   

    不能写范围,可以用case when 替换.
    case when time<120 then '20'
         when time >120 and time<300 then '3-5'
         end
      

  3.   

    非要用decode的话,就用sign函数凑合一下
    decode(-1,sign(time-1)*sign(time-120),...,sign(time-120)*sign(time-300),...)
    当然效率低是显而易见的