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, Venkatesh.
Asked: March 21, 2017 - 5:26 am UTC
Last updated: March 23, 2017 - 11:23 am UTC
Version: 11.2.0.4
Viewed 1000+ times
SQL> variable acct varchar2(30) SQL> exec :acct := '123,456,789' SQL> select substr(:acct, 2 nvl(lag(loc) over ( order by loc),0)+1, 3 loc-nvl(lag(loc) over ( order by loc),0)-1 4 ) list_as_rows 5 from ( 6 select distinct (instr(:acct||',',',',1,level)) loc 7 from dual 8 connect by level <= length(:acct)-length(replace(:acct,','))+1 9 ); LIST_AS_ROWS -------------------------------- 123 456 789
Analytic SQL got you confused? Check out Connor McDonald's complete video course.