<tfoot id='2cQIY'></tfoot>
    1. <small id='2cQIY'></small><noframes id='2cQIY'>

    2. <legend id='2cQIY'><style id='2cQIY'><dir id='2cQIY'><q id='2cQIY'></q></dir></style></legend>

      <i id='2cQIY'><tr id='2cQIY'><dt id='2cQIY'><q id='2cQIY'><span id='2cQIY'><b id='2cQIY'><form id='2cQIY'><ins id='2cQIY'></ins><ul id='2cQIY'></ul><sub id='2cQIY'></sub></form><legend id='2cQIY'></legend><bdo id='2cQIY'><pre id='2cQIY'><center id='2cQIY'></center></pre></bdo></b><th id='2cQIY'></th></span></q></dt></tr></i><div id='2cQIY'><tfoot id='2cQIY'></tfoot><dl id='2cQIY'><fieldset id='2cQIY'></fieldset></dl></div>
        <bdo id='2cQIY'></bdo><ul id='2cQIY'></ul>

        Oracle - 字符串组合排列

        Oracle - string combinatorial permutation(Oracle - 字符串组合排列)

          • <i id='VA6Qn'><tr id='VA6Qn'><dt id='VA6Qn'><q id='VA6Qn'><span id='VA6Qn'><b id='VA6Qn'><form id='VA6Qn'><ins id='VA6Qn'></ins><ul id='VA6Qn'></ul><sub id='VA6Qn'></sub></form><legend id='VA6Qn'></legend><bdo id='VA6Qn'><pre id='VA6Qn'><center id='VA6Qn'></center></pre></bdo></b><th id='VA6Qn'></th></span></q></dt></tr></i><div id='VA6Qn'><tfoot id='VA6Qn'></tfoot><dl id='VA6Qn'><fieldset id='VA6Qn'></fieldset></dl></div>
          • <tfoot id='VA6Qn'></tfoot>

            • <legend id='VA6Qn'><style id='VA6Qn'><dir id='VA6Qn'><q id='VA6Qn'></q></dir></style></legend>
                  <tbody id='VA6Qn'></tbody>
                  <bdo id='VA6Qn'></bdo><ul id='VA6Qn'></ul>

                  <small id='VA6Qn'></small><noframes id='VA6Qn'>

                  本文介绍了Oracle - 字符串组合排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想我有一个复杂的要求.

                  I think I have a complex requirement.

                  这是一个使用 Oracle 10.2 的组合排列,我能够使用笛卡尔连接解决它,但我认为它需要一些改进以使其更简单和更灵活.

                  It's a combinatorial permutation using Oracle 10.2, I'was able to solve it using cartesian joins, but I think that it need some improvements to made it simplest and more flexible.

                  主要行为.

                  输入字符串:'一二'

                  输出:'一''二''一二'两个一"

                  output: 'one' 'two' 'one two' 'two one'

                  对于我的解决方案,我将字符串的数量限制为 5(请注意,输出是阶乘附近的数字)

                  For my solution I've restricted the number of strings to 5 (note that the output is a number near the factorial)

                  SQL:

                  with My_Input_String as (select 1 as str_id, 'alpha beta omega gama' as str from dual )
                  
                  --------logic-------
                  
                  , String_Parse as (
                                      SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, ROWNUM) str
                                      FROM My_Input_String
                                      where rownum < 6 -- string limitation --
                                      CONNECT BY level <= LENGTH(REGEXP_REPLACE(str, '([^ ])+|.', '1') ) 
                                    )    
                  
                  --------CRAP select need refactoring-------
                  
                  select str from String_Parse
                  union
                  select  REGEXP_REPLACE(trim(s1.str||' '||s2.str||' '||s3.str||' '||s4.str||' '||s5.str), '( ){2,}', ' ') as str
                  from 
                  
                  (select str from String_Parse union select ' ' from dual) s1,
                  (select str from String_Parse union select '  ' from dual) s2,
                  (select str from String_Parse union select '   ' from dual) s3,
                  (select str from String_Parse union select '    ' from dual) s4,
                  (select str from String_Parse union select '     ' from dual) s5
                  where 
                  --
                  s1.str <> s2.str and s1.str <> s3.str and s1.str <> s4.str and s1.str <> s5.str
                  --
                  and s2.str <> s3.str and s2.str <> s4.str and s2.str <> s5.str
                  --
                  and s3.str <> s4.str and s3.str <> s5.str
                  --
                  and s4.str <> s5.str
                  

                  推荐答案

                  得到了通用的.最后真的很简单(但我花了一段时间才到达那里)

                  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:删除了多余的 maxnum 内容.之前尝试的遗留问题

                  Removed redundant maxnum stuff. Left over from previous attempts

                  这篇关于Oracle - 字符串组合排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                    <legend id='9VSTy'><style id='9VSTy'><dir id='9VSTy'><q id='9VSTy'></q></dir></style></legend>
                  1. <i id='9VSTy'><tr id='9VSTy'><dt id='9VSTy'><q id='9VSTy'><span id='9VSTy'><b id='9VSTy'><form id='9VSTy'><ins id='9VSTy'></ins><ul id='9VSTy'></ul><sub id='9VSTy'></sub></form><legend id='9VSTy'></legend><bdo id='9VSTy'><pre id='9VSTy'><center id='9VSTy'></center></pre></bdo></b><th id='9VSTy'></th></span></q></dt></tr></i><div id='9VSTy'><tfoot id='9VSTy'></tfoot><dl id='9VSTy'><fieldset id='9VSTy'></fieldset></dl></div>
                    • <bdo id='9VSTy'></bdo><ul id='9VSTy'></ul>

                      <small id='9VSTy'></small><noframes id='9VSTy'>

                      <tfoot id='9VSTy'></tfoot>

                          <tbody id='9VSTy'></tbody>