with t (수량) as (
select 50 from dual union all
select 30 from dual union all
select 45 from dual union all
select 0 from dual union all
select 0 from dual union all
select 0 from dual union all
select 9 from dual union all
select 20 from dual union all
select 0 from dual)
select b.수량, aa.rn2 순번
from (
select 수량,rn,row_number() over(order by rownum) rn2
from (
select 수량,row_number() over(order by rownum) rn
from t a)
where 수량 <> 0
) aa
,(select 수량,rownum gb from t order by rownum) b
where aa.rn (+) = b.gb
order by gb;