select Val,rn,cnt
from (select column_value as Val,
-1+Row_Number() over(order by column_value) as rn,
-1+count(*) over() as cnt
from table(sys.odciNumberList(10,20,30,40,50,60,70,80,90)))
order by
case rn when cnt then 1 else 0 end,
mod(rn,cnt/2),rn;
Val rn cnt
--- -- ---
10 0 8
50 4 8
20 1 8
60 5 8
30 2 8
70 6 8
40 3 8
80 7 8
90 8 8
select Val,rn,cnt
from (select column_value as Val,
-1+Row_Number() over(order by column_value) as rn,
-1+count(*) over() as cnt
from table(sys.odciNumberList(10,20,30,40,50,60,70,80,90,100)))
order by
case rn when cnt then 1 else 0 end,
mod(rn,cnt/2),rn;
Val rn cnt
--- -- ---
10 0 9
60 5 9
20 1 9
70 6 9
30 2 9
80 7 9
40 3 9
90 8 9
50 4 9
100 9 9