本帖最后由 zwh5067177 于 2010-11-27 12:07:13 编辑

解决方案 »

  1.   

    [code=SQL]
    --------先按照id的长度排序desc,然后按照id ascSQL> 
    SQL> with tab as
      2  (select 1 id,'记账凭证打印' name from dual union all
      3  select 2 id,'记账凭证和纸质报账单顺号、匹配' name from dual union all
      4  select 3 id,'二次检查和组卷' name from dual union all
      5  select 4 id,'内部交接' name from dual union all
      6  select 5 id,'组盒' name from dual union all
      7  select 6 id,'入库' name from dual union all
      8  select 2293 id,'发起流程' name from dual union all
      9  select 2294 id,'县局接收' name from dual union all
     10  select 2295 id,'县局发送' name from dual union all
     11  select 2296 id,'登记接收' name from dual union all
     12  select 2297 id,'票据扫描' name from dual
     13  )
     14  select id ,name from tab order by length(to_char(id)) desc,id
     15  ;        ID NAME
    ---------- ---------------------------------------------
          2293 发起流程
          2294 县局接收
          2295 县局发送
          2296 登记接收
          2297 票据扫描
             1 记账凭证打印
             2 记账凭证和纸质报账单顺号、匹配
             3 二次检查和组卷
             4 内部交接
             5 组盒
             6 入库11 rows selectedSQL> 
    [code]
      

  2.   

    SQL> 
    SQL> with tab as
      2  (select 1 id,'记账凭证打印' name from dual union all
      3  select 2 id,'记账凭证和纸质报账单顺号、匹配' name from dual union all
      4  select 3 id,'二次检查和组卷' name from dual union all
      5  select 4 id,'内部交接' name from dual union all
      6  select 5 id,'组盒' name from dual union all
      7  select 6 id,'入库' name from dual union all
      8  select 2293 id,'发起流程' name from dual union all
      9  select 2294 id,'县局接收' name from dual union all
     10  select 2295 id,'县局发送' name from dual union all
     11  select 2296 id,'登记接收' name from dual union all
     12  select 2297 id,'票据扫描' name from dual
     13  )
     14  select id ,name from tab order by length(to_char(id)) desc,id
     15  ;        ID NAME
    ---------- ---------------------------------------------
          2293 发起流程
          2294 县局接收
          2295 县局发送
          2296 登记接收
          2297 票据扫描
             1 记账凭证打印
             2 记账凭证和纸质报账单顺号、匹配
             3 二次检查和组卷
             4 内部交接
             5 组盒
             6 入库11 rows selectedSQL> 
      

  3.   


    order by length(t.tache_id) desc,tache_id
      

  4.   

    先按tache_id
    长度最长的降序排序 长度相同的则按其tache_id 的升序排序
      

  5.   


    Select t.tache_id, t.tache_name
      from t_tache t, t_config c
     where t.tache_id = c.tache_id and c.count_unit = 1
     order by decode(length(t.tache),1 ,1 ,0), t.tache_id
      

  6.   

    Select t.tache_id, t.tache_name
      from t_tache t, t_config c
     where t.tache_id = c.tache_id and c.count_unit = 1
     order by  length(to_char(tache_id)) desc,tache_id