为什么有空格的行在中间??select * from tbname order by b,id; 这个不行?

解决方案 »

  1.   

    SQL> select * from tb;        ID A          B
    ---------- ---------- ----------
             1 001        10
             2 002
             3 003        11
             4 004        10
             5 005        11
             6 006        10已选择6行。SQL> select id,a,b from(
      2  select min(id) over(partition by b) mid,id,a,b from tb
      3  ) order by mid||'~'||b;        ID A          B
    ---------- ---------- ----------
             1 001        10
             4 004        10
             6 006        10
             2 002
             3 003        11
             5 005        11已选择6行。SQL>
      

  2.   

    select 
        * 
    from 
        表 
    order 
        by decode(B,'10',1,' ',2,'11',3),ID
      

  3.   

    感谢bzszp(SongZip)的帮助,谢谢CCTV.谢谢MTV.谢谢大家.....^O^
    同时感谢libin_ftsafe(子陌红尘) 的回答,对定死的分组项可以这样写的^_^