1、select rn, ltrim(max(sys_connect_by_path(product, ',')), ',') product
from
(
select rn, product, min(product) over(partition by rn) product_min
,(row_number() over(order by rn, product)) + (dense_rank() over(order by rn)) numId
from
(
select b.rn, a.rn || '*' || b.rn || '=' || a.rn * b.rn product
from (select rownum rn from all_objects where rownum <= 9) a,
(select rownum rn from all_objects where rownum <= 9) b
where a.rn <= b.rn
order by b.rn, product
)
)
start with product = product_min
connect by numId - 1 = prior numId
group by rn;
2、select ltrim(sys_connect_by_path
(rownum || '*' || lv || '=' || rpad(rownum * lv, 2),' ')
)
from (select level lv from dual connect by level < 10)
where lv = 1
connect by lv + 1 = prior lv;
3、select reverse(sys_connect_by_path
(reverse(rpad(rownum * lv, 2)) || '=' || rownum || '*' || lv ,' ')
)
from (select level lv from dual connect by level < 10)
where lv = 1
connect by lv + 1 = prior lv;
4、with t as (select level as n from dual connect by level <=9)
select max(substr(sys_connect_by_path(b.n || '*' || a.n || '=' || a.n * b.n, ', '),3)) as val
from t a, t b
where a.n >= b.n
start with b.n=1
connect by a.n=prior a.n and b.n=prior b.n+1
group by a.n;
5、with t as (select level as n from dual connect by level <=9)
select substr(sys_connect_by_path(b.n || '*' || a.n || '=' || a.n * b.n, ' '),2) as val
from t a, t b
where a.n >= b.n and level = a.n
start with b.n=1
connect by a.n=prior a.n and b.n=prior b.n+1;