select * from table where f1>=3 order by f1
union 
select * from table where f1 in (1,2) order by f1

解决方案 »

  1.   

    select * from tbname order by decode(f1,1,99999998,2,99999999,f1);
      

  2.   

    select * from table where f1>2 order by f1
    union 
    select * from table where f1<3 order by f1
      

  3.   

    select * from table where f1>2 order by f1
    union 
    select * from table where f1<3 order by f1
    不行,报错。ORA-00933 SQL command not properly ended
      

  4.   

    用这个可以,不过就是有点缺陷
    select * from tbname order by decode(f1,1,99999998,2,99999999,f1);
    不知道表里的f1值会不会超过指定的数99999999
      

  5.   

    ORDER BY不能这么用。
    只能在UNION后用一次。
    如:
    select * from table where f1>2 
    union 
    select * from table where f1<3 order by 1
      

  6.   

    怕F1超过99999999的,可以这样:
    select * from tbname order by decode(f1,1,'a',2,'b',f1);
      

  7.   

    谢谢各位,另外,sybase有类似的decode的函数吗?