Oracle columns of multiple rows of data are spelled into a single line of characters
oracle provides two functions Wmsys.wm_concat and Listagg functions. www.2cto.com First Introduction: wmsys.wm_concat Example: ID name 1 aa 2 bb 3 cc knot The fruit is "aa,bb,cc" select Wmsys. Wm_concat (a.name) from User A In this case, the query results: "AA,BB,CC" www.2cto.com delimiter If you do not need to use the English comma, you need to change to other symbols such as semicolons, You can replace it with the following method: Select Replace (Wmsys. Wm_concat (A.name), ', ', '; ') from User a result: "AA;BB;CC" ============================================================== The syntax structure of the ========LISTAGG function Listagg function is as follows: listagg ([,]) within GROUP (ORDER by) [Over (PARTITION by)] Listagg is an aggregation function, but it can provide analysis functionality (such as an optional over () clause). With Listagg, the elements in the following are required: www.2cto.com The column or expression that needs to be aggregated with Group keyword group ORDER BY clause example: deptno ename------------------- 10 clark 10 king & nbsp 10 MILLER&NBSp 20 adams 20 ford 20 Jones Group by Deptno field, string aggregation of result sets , the results are as follows: DEPTNO aggregated_enames---------------------------------- clark,king,miller 20 Adams,ford,jonessql:select Deptno,listagg (ename, ', ') within group (ORDER by ename) as employees from emp GROUP by D Eptno;
Multiple rows of data in an Oracle column are spelled in one line of characters