Multi-row data in the Oracle column is combined into one line of display characters

Source: Internet
Author: User

The multi-row data in the Oracle column is combined into one display character. oracle provides two functions: WMSYS. WM_CONCAT and listparts. Www.2cto.com: WMSYS. WM_CONCAT example: id name 1 aa 2 bb 3 cc results in "aa, bb, cc" select WMSYS. WM_CONCAT (. name) from user a, the query result is: "aa, bb, cc" www.2cto.com separator. If you do not need to use a comma, you need to change it to another symbol, such as a semicolon, you can use the following method to replace: select replace (WMSYS. WM_CONCAT (. name), ';') from user a result: "aa; bb; cc "============================================ ================================== the syntax structure of the listparts function is as follows:: listparts ([,]) within group (ORDER) [OVER (partition by)] Although listparts is an aggregate function, it can provide analysis functions (for example, an optional OVER () clause ). When listparts is used, the following elements are required: www.2cto.com • columns or expressions to be aggregated • with group keyword • order by clause example in the GROUP: deptno ename --------- ---------- 10 CLARK 10 KING 10 MILLER 20 ADAMS 20 FORD 20 JONES group the result set according to the DEPTNO field. The result is as follows: DEPTNO AGGREGATED_ENAMES --------- --------------------- 10 CLARK, KING, MILLER 20 ADAMS, FORD, JONESSQL: SELECT deptno, listparts (ename, ',') within group (order by ename) AS employees FROM emp group by deptno;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.