The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, Sunny.
Asked: April 03, 2019 - 4:52 pm UTC
Last updated: April 09, 2019 - 1:32 am UTC
Version: 12c
Viewed 1000+ times
SQL> create table t ( x int ); Table created. SQL> insert into t values (10); 1 row created. SQL> insert into t values (20); 1 row created. SQL> insert into t values (30); 1 row created. SQL> insert into t values (60); 1 row created. SQL> insert into t values (40); 1 row created. SQL> insert into t values (70); 1 row created. SQL> insert into t values (99); 1 row created. SQL> insert into t values (90); 1 row created. SQL> insert into t values (80); 1 row created. SQL> SQL> with tt (elem, tot , str) as 2 ( select x elem, x tot , to_char(x) str 3 from t 4 union all 5 select x, tot+x, str||','||x 6 from tt, t 7 where t.x > tt.elem 8 ) 9 select str from tt 10 where tot = 110; STR ------------------------------ 20,90 30,80 40,70 10,20,80 10,30,70 10,40,60 20,30,60 7 rows selected.
Racer I., April 05, 2019 - 6:47 am UTC
with pt as ( select x, ROW_NUMBER() OVER (ORDER BY x) pos from t), tt(elem, tot, str, pos) as ( select x elem, x tot, to_char(x) str, pos from pt union all select x, tot + x, str || ',' || x, pt.pos from tt, pt where pt.pos > tt.pos) select str from tt where tot = 110 insert into t values (20); 10,20,20,60
Sokrates, April 08, 2019 - 12:55 pm UTC
The Oracle documentation contains a complete SQL reference.