解决方案 »

  1.   

    估计楼主是多写了个4,应该是想找出不同的数放在前面,重复出现的数按大小放在所有不同的数的后面,如果用代码实现倒是可以,sql还真没试过
      

  2.   

    我测试了一下,应该是可以的:select t.id
      from (select distinct t.id, 1 seq
              from test5 t
            union all
            select t1.id, 2 seq
              from (select t.id,
                           row_number() over(partition by t.id order by t.id) rn
                      from test5 t) t1
             where t1.rn > 1
             order by seq, id) t;
      

  3.   

    with t as(
    select 1 aa from dual
    union all select 2 from dual
    union all select 3 from dual
    union all select 5 from dual
    union all select 6 from dual
    union all select 7 from dual
    union all select 3 from dual
    union all select 4 from dual
    union all select 4 from dual
    union all select 5 from dual
    union all select 3 from dual
    )
     select aa
       from (select aa, count(1) bb
               from t
              group by aa)
    connect by bb - level >= 0
      group by level, aa
      order by level, aa;
    不知道还有没有用