分组合并多列
Jun 07, 2016 pm 02:56 PM
Group
merge
multiple columns
Version
Oracle9i及以前的版本中,没有可直接支持的分组后,用某个特殊字符进行分隔列 像10g有wm_concat,11g可以用listagg(字段,分隔字符) within group(order by 字段) Oracle SELECT 分组列,ltrim(MAX(sys_connect_by_path(字符串列,',')),',')FROM (SELECT 分组列
Oracle9i及以前的版本中,没有可直接支持的分组后,用某个特殊字符进行分隔列像10g有wm_concat,11g可以用listagg(字段,分隔字符) within group(order by 字段)
Oracle
SELECT 分组列,ltrim(MAX(sys_connect_by_path(字符串列,',')),',') FROM ( SELECT 分组列,字符串列,rank()over(ORDER BY 分组列) + row_number()over(order by 分组列) RN,row_number()over(partition by 分组列 order by 分组列) RM FROM 表) start with RM=1 connect by prior RN=RN-1 group by 分组列 ; --在FROM 表这个地方你可以过滤掉这些空值 --或在ltrim(MAX(sys_connect_by_path(字符串列,',')),',')这个地方 --再加个这个就可以rtrim(ltrim(MAX(sys_connect_by_path(字符串列,',')),','),',')
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Tutorial on updating curl version under Linux!

Simple steps to update pip version: done in 1 minute

Check the Kirin operating system version and kernel version

Interpret the meaning and difference of PHP version NTS

How to easily install Python on Windows, you can choose from two methods

How to easily check the installed version of Oracle
