clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36293 in the last week).

with s(r,i)as(select row_number()over(order by(rand()))r,*from string_split('7,6,5,4,3,2,1',','))select string_agg(l.i,',')from s,s l where l.r>s.r-s.i and l.r<=s.r and s.r-s.i>=0group by s.i
(No column name)
1
3,2
5,4,3
7,6,5,4
 hidden batch(es)