Oracle - string combinatorial permutation

a 夏天 提交于 2019-11-30 20:25:15

Edit: Got the generic one. Really simple in the end (but took me a while to get there)

WITH words AS
(   SELECT  REGEXP_SUBSTR( '&txt', '\S+', 1, LEVEL )    AS word
        ,   LEVEL                                       AS num
    FROM    DUAL
    CONNECT BY LEVEL <= LENGTH( REGEXP_REPLACE( '&txt', '\S+\s*', 'X' ) )
)
SELECT  SYS_CONNECT_BY_PATH( W.word, ' ' )
FROM    words   W
CONNECT BY NOCYCLE PRIOR W.num != W.num

Edit2: Removed redundant maxnum stuff. Left over from previous attempts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!