select tab1.*,1 R from tab1 where filed1 = '1'
union
select tab1.*,2 from tab1 where filed1 = '3'
union
select tab1.*,3 from tab1 where filed1 = '2'
order by R

解决方案 »

  1.   

    一般都是
    select * from tab1 where filed1 in ('1', '3', '2') order by filed1 Asc(或者desc)这种情况可以:
    filed1  filed2
    1       1
    2       3
    3       2
    select * from (select * from tab1 where filed1 in(1,2,3) order by filed1) order by filed2
    结果:1
          3
          2
      

  2.   

    要么只能向楼上feng2(蜀山风云)说的用Union all 了
      

  3.   

    select * from tab1 where filed1 in ('1', '3', '2')
    order by decode(filed1,'1','1','3','2','2','3','4')
      

  4.   

    用xiaoxiao1984(笨猫儿^_^)的方法不错
      

  5.   

    select * 
    from tab1 
    where filed1 in ('1', '3', '2')
    order by instr(','||'1,3,2'||',',','||filed1||',')
    '1','3','2'作为参数外部传入,替换一下就可以了
    其实就是按照出现的顺序排序
      

  6.   

    xiaoxiao1984(笨猫儿^_^) 的方法不错,巧妙地运用了decode()函数.强力顶一下,哈
      

  7.   

    呵呵,谢谢各位,decode的方式还是不好,因为个数比较多,decode有限制的,我已经通过其他途径操作了。