Skip to content

Instantly share code, notes, and snippets.

@xtender
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtender/9998182 to your computer and use it in GitHub Desktop.
Save xtender/9998182 to your computer and use it in GitHub Desktop.
listagg-model
with t1 as (select level id from dual connect by level<=10)
,t2 as (select level id, 'a'||level v from dual connect by level<=10)
select
id,
(select rtrim(new_v,',')
from t2
where t2.id<=t1.id
model
return updated rows
dimension by (rownum rn)
measures(cast(null as varchar2(4000)) new_v, v)
rules iterate(1e6) until(presentv(new_v[iteration_number+2],1,0)=0)
(
new_v[0]=new_v[0]||v[iteration_number+1]||','
)
)
from t1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment