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

  3. <legend id='mICo5'><style id='mICo5'><dir id='mICo5'><q id='mICo5'></q></dir></style></legend>

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

      如何在不创建存储过程的情况下在 Oracle 中将多行连接为一个?

      时间:2023-09-20
    2. <small id='QyE6k'></small><noframes id='QyE6k'>

        <tbody id='QyE6k'></tbody>
      • <tfoot id='QyE6k'></tfoot>
          <bdo id='QyE6k'></bdo><ul id='QyE6k'></ul>

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

              • <legend id='QyE6k'><style id='QyE6k'><dir id='QyE6k'><q id='QyE6k'></q></dir></style></legend>
              • 本文介绍了如何在不创建存储过程的情况下在 Oracle 中将多行连接为一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在不创建存储过程的情况下在oracle中实现以下功能?

                How can I achieve the following in oracle without creating a stored procedure?

                数据集:

                question_id    element_id
                1              7
                1              8
                2              9
                3              10
                3              11
                3              12
                

                预期结果:

                question_id    element_id
                1              7,8
                2              9
                3              10,11,12
                

                推荐答案

                进行字符串聚合的方法有很多,但最简单的是用户定义函数.试试这个不需要函数的方法. 作为注释,没有功能就没有简单的方法.

                There are many way to do the string aggregation, but the easiest is a user defined function. Try this for a way that does not require a function. As a note, there is no simple way without the function.

                这是没有自定义函数的最短路径:(它使用 ROW_NUMBER() 和 SYS_CONNECT_BY_PATH 函数)

                This is the shortest route without a custom function: (it uses the ROW_NUMBER() and SYS_CONNECT_BY_PATH functions )

                SELECT questionid,
                       LTRIM(MAX(SYS_CONNECT_BY_PATH(elementid,','))
                       KEEP (DENSE_RANK LAST ORDER BY curr),',') AS elements
                FROM   (SELECT questionid,
                               elementid,
                               ROW_NUMBER() OVER (PARTITION BY questionid ORDER BY elementid) AS curr,
                               ROW_NUMBER() OVER (PARTITION BY questionid ORDER BY elementid) -1 AS prev
                        FROM   emp)
                GROUP BY questionid
                CONNECT BY prev = PRIOR curr AND questionid = PRIOR questionid
                START WITH curr = 1;
                

                这篇关于如何在不创建存储过程的情况下在 Oracle 中将多行连接为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Oracle JDBC ojdbc6 Jar 作为 Maven 依赖项 下一篇:Oracle:导入 CSV 文件

                相关文章

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

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

                  1. <legend id='9H8Z2'><style id='9H8Z2'><dir id='9H8Z2'><q id='9H8Z2'></q></dir></style></legend>
                    <tfoot id='9H8Z2'></tfoot>