order by 怎么处理?where能不能通过exist,decode,sign之类的处理?

解决方案 »

  1.   

    你准备得到什么样的答案?
    c>=0正排,c<0逆排?
      

  2.   

    order by decode (sign(c),1,c,-1,abs(c)+(select max(abs(c)) from table))
      

  3.   

    其实order by 应该是第4个字段d,整个sql原本应用在PL/SQL里面,c是一个输入参数,当c>0时,条件需要A>=B,且D列顺序,当C<0时,条件A<B,且D列反序。原来的储存过程因为已经有3层Loop了,不想再建2个游标进行分别Loop
      

  4.   

    select * from table 
    where c>=0 and a>b or c<0 and a<b 
    order by sign(c) desc, abs(c);