• + 0 comments

    WITH A AS ( SELECT LEVEL AS L FROM DUAL CONNECT BY LEVEL <= 1000 ) SELECT LISTAGG(L,'&') WITHIN GROUP (ORDER BY L) FROM ( SELECT L FROM A MAIN WHERE NOT EXISTS ( SELECT 1 FROM A SUB WHERE MAIN.L>SUB.L AND MOD(MAIN.L,L)=0 AND SUB.L>1 ) AND L<>1 );