Reg: String aggregation-

Hi Experts,

I have a scenario where my query returns 4 ranks as
A
B
C
D
-Results: ' a ',' B', 'C', d '.

How can I achieve this using the aggregation of String?

I'm working on-
SELECT CHR (39)||RTRIM(XMLAGG (XMLELEMENT (e, <table_column>||''',''')).EXTRACT ('//text()'),''',''')|| CHR (39)
  FROM <my_table>;
but give...
'QFND340B&apos;,&apos;QFND434&apos;,&apos;'
Database details - 
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE     10.2.0.3.0     Production
TNS for Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

Try like this:

select WM_CONCAT(''''||lvl||'''') from (
                          SELECT 'A' AS lvl FROM DUAL union all
                          SELECT 'B' AS lvl FROM DUAL union all
                          SELECT 'C' AS lvl FROM DUAL union all
                          SELECT 'D' AS lvl FROM DUAL
                          ) xx;

Tags: Database

Similar Questions

  • Query (connect / string aggregation)

    Hello
    Can someone give me an example of a query


    VAL ID
    --------
    2B
    1 B
    1 C


    Output: "A, B, C".

    Thank you.

    Published by: Bolev on February 3, 2010 17:10

    Hello

    Pivot generates separate columns for each val, and you should know how much they will be.

    String aggregation provides a single column and does not need to know how many vals there will be:

    WITH     got_rnum     AS
    (
         SELECT     id
         ,     val
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          val
                           ) AS rnum
         FROM    table_x
    )
    SELECT     id
    ,     LTRIM ( SYS_CONNECT_BY_PATH (val, ',')
               , ','
               )     AS val_list
    FROM     got_rnum
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     rnum     = 1
    CONNECT BY     rnum     = PRIOR rnum + 1
         AND     id     = PRIOR id
    ;
    
  • string aggregation 4000 +.

    Hi all

    I'm using Oracle 11.2.0.3.   I used LISTAGG to generate CSV values for names, but some of my values are greater than 4000 characters, it is throwing ORA-01489: result of concatenating string is too long.

    I tried to XMLAGG allowing to solve. However, this special character space.  (e.g. & be escaped to & the equivalent of xml security)

    for example

    with t as

    (SELECT ' has "PEOPLE ' as double fname)

    Union of all the

    SELECT ' BALL &' as double fname

    Union of all the

    Select "cat!"  as double fname)

    Select rtrim (xmlagg (xmlelement (e, fname,',').extract('//text () ') order of fname).) GetClobVal(), ',') AS NAME of t

    RETURNS: Has ' PEOPLE, BALL, & CAT!

    Has ' PEOPLE EXPECTED, BALL & CAT!

    Is it possible to disable escape everything using XMLAGG?

    Is there any other method recommended to use aggregation of chain for more than 4000 characters?

    Thank you very much!

    The following would be the correct way to do it in your version.

    Unescaping/cast the result as a CLOB will be XMLCast:

    with t as)

    Select ' has "PEOPLE ' as fname Union double all the

    Select ' BALL &' as fname Union double all the

    Select "cat!"  as double fname

    )

    Select rtrim)

    (xmlcast)

    XMLAGG)

    XmlElement (e, fname |) ',')

    order of the fname

    )

    as clob

    )

    , ','

    ) as name

    t;

    (in versions< 11.1,="" i="" would="" have="" used="" dbms_xmlgen.convert="" instead="" in="" order="" to="" unescape="" entity="">

  • string aggregation &gt; 4000 store in varchar2 (4000)

    Dear experts,

    I'm using Oracle 11.2.0.3. I have the table such as

    ID NAME

    1 xyz

    1 abc xyz

    1 xyz abc def

    2 abc

    2 xyz nmnx

    I want to aggregate them so that I have the aggregation of the NAME by ID

    as

    1XYZ xyz abc xyz abc def
    2ABC xyz nmnx

    I was able to do this using:

    WITH t
         AS (SELECT 1 AS id, 'xyz' AS name FROM DUAL
             UNION ALL
             SELECT 1, ' xyz abc' FROM DUAL
             UNION ALL
             SELECT 1, 'xyz abc  def' FROM DUAL
             UNION ALL
             SELECT 2, 'abc' FROM DUAL
             UNION ALL
             SELECT 2, 'xyz  nmnx' FROM DUAL)
    SELECT     id, RTRIM (XMLCAST (XMLAGG (XMLELEMENT (e, name, ' ') ORDER BY NULL) AS CLOB)) as agg_name
        FROM   t
    GROUP BY   id;
    
    

    However, if the length (agg_name) > 8 (for simplicity), then the name should be on a separate line with the same id

    1 xyz xyz

    1 abc def

    1 xyz ABC

    2 abc xyz

    2 nmnx

    token order is not important.

    Thanks for any help

    Above could be done using

    WITH t
         AS (SELECT 1 AS id, 'xyz' AS name FROM DUAL
             UNION ALL
             SELECT 1, ' xyz abc' FROM DUAL
             UNION ALL
             SELECT 1, 'xyz abc  def' FROM DUAL
             UNION ALL
             SELECT 2, 'abc' FROM DUAL
             UNION ALL
             SELECT 2, 'xyz  nmnx' FROM DUAL)
    SELECT     ID, LISTAGG (name) WITHIN GROUP (ORDER BY NULL) org_name
        FROM   (SELECT   ID,
                         name || ' ' name,
                         CEIL (SUM (len) OVER (PARTITION BY ID ORDER BY len) / 8) part,
                         len
                  FROM   (SELECT    /*distinct */  ID, x.name, LENGTH (x.name || ' ') len
                             FROM   t, XMLTABLE ('ora:tokenize(.," ")' PASSING ' ' || TRIM (name) COLUMNS name VARCHAR2 (4000) PATH '.') x
                            WHERE   x.name IS NOT NULL))
    GROUP BY   ID, part;
    
  • Parse qualified double quote delimited strings

    Hi all

    I have a few strings of data that I get I want to analyze. My problem is that I am not able to understand how I can analyze the fields that are double quote qualified ("19 999")?

    I played with the regex_substr, but I can't quite make what I want.

    I want to analyze the myString column in my example below in four areas:
    Product
    OnOrder
    OnHand
    TotalSold

    Here is an example... I've been playing with it for a bit, and I can't get it.
    WITH parseString AS (Select 
                            '"Grado, Headphones",123,2222,"19,999" ' myString
                         from dual
                         UNION ALL
                         Select 
                            'Audio Slave,222,3333,444' myString
                         from dual
                         
                                    )
    Select 
        myString
    from parseString
    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - 64bi
    PL/SQL version 10.2.0.3.0 - Production
    CORE Production 10.2.0.3.0
    AMT for Linux: release 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production


    Any suggestions greatly appreciated.

    S

    Published by: ScarpacciOne on April 22, 2010 15:24

    Hello

    As Centinul said, it would help a lot if you have published your desired results and explains how get you from the sample data.
    Here's something that can help, according to your specific needs:

    WITH     got_item_cnt     AS
    (
         SELECT     myString
         ,     1 + LENGTH (myString)
                - LENGTH (REPLACE (myString, ','))     AS item_cnt
         FROM     parsestring
    )
    ,     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= ( SELECT  MAX (item_cnt)
                           FROM    got_item_cnt
                         )
    )
    ,     comma_separated_values     AS
    (
         SELECT     i.myString
         ,     c.n
         ,     REGEXP_SUBSTR ( i.myString
                         , '[^,]+'
                         , 1
                         , c.n
                         )          AS value
         FROM     got_item_cnt     i
         JOIN     cntr          c     ON     c.n     <= i.item_cnt
    )
    ,     got_quote_cnt     AS
    (
         SELECT     myString
         ,     n
         ,     REPLACE (value, '"')     AS value
         ,     NVL ( SUM ( LENGTH (value)
                     - LENGTH (REPLACE (value, '"'))
                     ) OVER ( PARTITION BY  myString
                           ORDER BY      n
                           ROWS BETWEEN  UNBOUNDED PRECEDING
                             AND      1        PRECEDING
                            )
                  , 0
                  )          AS quote_cnt
         FROM     comma_separated_values
    )
    SELECT     myString
    ,     n
    ,     LTRIM ( SYS_CONNECT_BY_PATH (value, ',')
               , ','
               )          AS token
    FROM     got_quote_cnt
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     MOD (quote_cnt, 2)     = 0
    CONNECT BY     MOD (quote_cnt, 2)     = 1
         AND     myString     = PRIOR myString
         AND     n          = PRIOR n + 1
    ORDER BY     myString,     n
    ;
    

    Output of your sample data:

    MYSTRING                                N TOKEN
    -------------------------------------- -- --------------------
    "Grado, Headphones",123,2222,"19,999"   2 Grado, Headphones
    "Grado, Headphones",123,2222,"19,999"   3 123
    "Grado, Headphones",123,2222,"19,999"   4 2222
    "Grado, Headphones",123,2222,"19,999"   6 19,999
    Audio Slave,222,3333,444                1 Audio Slave
    Audio Slave,222,3333,444                2 222
    Audio Slave,222,3333,444                3 3333
    Audio Slave,222,3333,444                4 444
    

    The basic strategy is to divide myString to all the commas, then re - unite consecutive elements that are in double - quotes.
    You never said what version of Oracle are you uisng.
    This solution works in Oracle 10.1. REGEXP_COUNT, introduced in Oracle 11.1, would make it a bit simpler.

    Here is each subquery:
    got_item_count finds the number of elements by commas in each myString
    CNTR generates integers 1, 2, 3,... until the maximum number of elements by commas on line any
    comma_separated_values myString splits its different elements, ignoring the quotes at the moment. I assumed myString is unique. If this isn't the case, you need some other unique identifier for each row of parsestring.
    * quote_cnt had "notes how quotes took place in myString, each element not included.  If (and only if) this number is odd, then the element is really a continuation of a previous item, in other words, the comma that separates this point from the previous one was within quotation marks and therefore should not have divided myString.  I assumed that the double-quote character always indicates the grouping; It is never to be taken literally, and therefore the final results will never contain quotes.
    The main query string aggregation on consecutive points, bringing together all the elements that are weird quote_cnts with the last item previous had a same quote_cnt.

    Published by: Frank Kulash, 22 April 2010 23:33

  • Remove duplicates of LISTAGG

    Oracle 11 g 2 Server

    You need to remove from a call LISTAGG dups.

    create table ptpos_explanations (
        id    number ,
        fr_id number ,
        part_type_id   number ,
        position_id    number ,
        ptpos_list     varchar2(4000)
    );
    
    insert into ptpos_explanations
    values(182527,100, 10,1,'It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100');
    
    
    insert into ptpos_explanations
    values(182527,100, 10,2,'It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100');
    
    
    insert into ptpos_explanations
    values(182527,110, 20,1,'It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100');
    
    insert into ptpos_explanations
    values(182527,110, 20,2,'It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100');
    
    commit;
    
    select * from ptpos_explanations;
    
            ID      FR_ID PART_TYPE_ID POSITION_ID
    ---------- ---------- ------------ -----------
    PTPOS_LIST
    -----------------------------------------------------------------------------------------------------------------------------
        182527        100           10           1
    It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100
    
        182527        100           10           2
    It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100
    
        182527        110           20           1
    It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100
    
        182527        110           20           2
    It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100
    
    
    4 rows selected.
    
    

    Can I use LISTAGG on ptpos_list to refine the results.

    SELECT  id, part_type_id, LISTAGG(ptpos_list,', ') WITHIN GROUP(ORDER BY ptpos_list) recommendations
    FROM     ptpos_explanations
    GROUP BY id, part_type_id ;
    
    
            ID PART_TYPE_ID
    ---------- ------------
    RECOMMENDATIONS
    -----------------------------------------------------------------------------------------------------------------------------
        182527           10
    It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100, It seems like it was replaced by part_type(
    s)/position(s):10/1 from content: 100
    
        182527           20
    It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100, It seems like it was replaced by part_type(
    s)/position(s):20/2 from content: 100
    
    
    

    However, there are duplicates in the recommendations. I tried to wrap LISTAGG inside a REGEXP_REPLACE function, without much success.

    Here the final result, so I'm looking for:

            ID PART_TYPE_ID
    ---------- ------------
    RECOMMENDATIONS
    ---------------------------------------------------------------------------------
        182527           10
    It seems like it was replaced by part_type(s)/position(s):10/1 from content: 100
    
        182527           20
    It seems like it was replaced by part_type(s)/position(s):20/2 from content: 100
    
    
    

    EDIT: There are "n" lines for ptpos_list. So, we need to manage the many values of ptpos_list.

    Hello

    This is a feature annoying LISTAGG - you cannot use DIFFERENT with her.

    A workaround is to to a separate GROUP BY, or SELECT DISTINCT simply get the unique values, then call LISTAGG on these unique results, like this:

    WITH got_distinct_ptpos_list AS

    (

    SELECT id, part_type_id, ptpos_list

    OF ptpos_explanations

    GROUP BY id, part_type_id, ptpos_list

    )

    SELECT id, part_type_id

    LISTAGG (ptpos_list, ',')

    THE Group (ORDER BY ptpos_list) in the form of recommendations

    OF got_distinct_ptpos_list

    GROUP BY id, part_type_id

    ;

    LISTAGG isn't the only way to get the desired results.  See https://oracle-base.com/articles/misc/string-aggregation-techniques for other ways to string aggregation, including a user-defined aggregate function and SYS_CONNECT_BY_PATH.

    REGEXP_REPLACE should work, too.  What exactly have you tried?  (However, it is probably more effective to get the unique results immediately the bat, rather than producing more than you want and then by doing something more to get rid of the duplicates).

  • Need to concat lines to a single column

    Hi all

    Some examples of data.

    col1 col2 col3

    125 200 abc

    126 200 def

    127 200 IGS

    128 210 homeless

    129 rte 210

    130 211 uiy

    I need output like this.

    col2 col3

    200 abc, def, ghi

    210 homeless, rte

    uiy 211

    I need data with order of col1

    Could you please let me know how to build the query for this.

    Thanks in advance.

    Hello

    Use the function of aggregation LISTAGG, like this:

    SELECT col2

    LISTAGG (col3, ",") THE Group (ORDER BY col1) AS col3_list,

    FROM table_x

    GROUP BY col2

    ;

    This requires that you use Oracle 11.2 or greater.

    The generic term for this is the String aggregation.

    For more on the aggregation of the chain, including how to do this in earlier versions of Oracle, see ORACLE-BASE - String aggregation Techniques

  • SQL output format

    Dear all,

    Select emp_no in emp;

    my output is

    1

    2

    3

    4

    But I want that as output format

    1,2,3,4

    Could you please tell me which application should I write it to achieve.

    Concerning

    Rajat

    Hi, Rajat,

    This is called the aggregation of the chain and this page:

    ORACLE-BASE - String aggregation Techniques

    shows several ways to do so.  What sense does use?  It depends on your requitrements and your version of Oracle.  The LISTAGG built-in aggregate function is good for most purposes.

  • multiple lines to one line

    I have two tables

    Employee1:

    State of name ID

    1SAMPA
    2JOHNGA
    3STEVETX

    Employee2:

    State of name ID

    1MARKCA
    1JOHNNORTH CAROLINA
    1DARRENTX

    my query is:

    Select e1.emp_id, e2.emp_name in e1, e2 employee2 employee1

    where e1.emp_id = e2.emp_id

    result:

    1MARK
    1JOHN
    1DARREN

    but I want the result in a line like below:

    ID EMP_NAME

    1 MARK, JOHN, DARREN

    How can I combine the query with separated by commas.

    Thank you.

    Hello

    872918 wrote:

    using IAM

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    PL/SQL Release 10.2.0.1.0 - Production

    This is an example of why you should always say what version of Oracle you are using, especially if this version is 9 years old.

    LISTAGG was new in Oracle 11.2.  In Oracle 10 (and more), you can use the SYS_CONNECT_BY_PATH, like this:

    WITH got_r_num AS

    (

    SELECT e1.emp_id

    e2.emp_name

    ROW_NUMBER () OVER (PARTITION BY e1.emp_id

    ORDER BY e2.emp_name

    ) AS r_num

    Of employee1 e1

    JOIN employee2 e2 ON e2.emp_id = e1.emp_id

    )

    SELECT emp_id

    LTRIM (SYS_CONNECT_BY_PATH (emp_name, ',')

    , ','

    ) AS all_enames

    OF got_r_num

    WHERE CONNECT_BY_ISLEAF = 1

    START WITH r_num = 1

    CONNECT BY r_num = r_num + 1

    AND emp_id = emp_id PRIOR

    ;

    Output of your sample data:

    EMP_ID ALL_ENAMES

    --------------- ---------------------------------------------

    1 DARREN, JOHN, MARK

    The generic name for this is the String aggregation.  For ways to string aggregation in different versions, see:

    ORACLE-BASE - String aggregation Techniques

  • need the output

    Hi all

    Player score

    10 001

    20 001

    20 002

    20 002

    10 001

    10 002

    20 003

    20 002

    10 001

    I want o/p in the select statement

    Player score

    001 10,20,10,10

    002 20,20,10,20

    20 003

    with t1 as

    (select the '001', '10' Score of double drive

    Union of all the

    Select the '001', '20' Score of double drive

    Union of all the

    Select the drive '002', '20' double Score

    Union of all the

    Select the drive '002', '20' double Score

    Union of all the

    Select the '001', '10' Score of double drive

    Union of all the

    Select the drive '002', '10' double Score

    Union of all the

    Select the drive '003', '20' double Score

    Union of all the

    Select the drive '002', '20' double Score

    Union of all the

    Select the '001', '10' Score of double drive)

    Select * from t1

    His pleasure... Try it for yourself... visit this link for examples:

    ORACLE-BASE - String aggregation Techniques http://www.Oracle-base.com/articles/10G/auditing-10gR2.php

  • Query Tunning

    Hi all

    I have the problem with the query. Can someone please help me with this...

    I have two tables namely xx_all and xx_lines_all

    xx_all has the following features

    flag of name alot_num

    1450 XXX Y

    1544 XYZ Y

    6598 ABC Y

    and xx_lines_all has the following features

    flag of field ext alot_num

    1450 1265 14 c Y

    1450 6541 15 c Y

    1450 7741 11A Y

    1544-1141-121 c Y

    1544 6541 14A Y

    I want to display the data as follows

    field of alot_num name ext

    1450 XXX 15547 14 c, 15 c, 11A

    1544 XYZ 7682 121C, 14A

    The ext above column is can be defined by group of sum (ext) (from table xx_lines_all) in alot_num (1265-6541-7741 = 15547 for alot_num = 1450)... And all the plots in xx_lines_all should come in one line for this particular alot_number as shown above, 14 c, 15 c, 11A to alot_num = 1450

    However, I am able to view the above format using functions but is at - it another way to display the format desired...

    Currently, there are in bulk records in the table causing delay to see the format for each line function call...

    I wrote functions just this one also check (if necessary)...

    Function to display the values of sum-

    CREATE OR REPLACE FUNCTION XX_EXT (P_ALOT_NUM NUMBER)

    RETURN NUMBER IS

    CURSOR CUR_PLOT_DAT

    IS

    PEX SELECT NVL (SUM (TO_NUMBER (ext)), 0)

    OF xx_lines_all

    WHERE LATEST_FLAG = 'Y '.

    AND ALOT_NUM = P_ALOT_NUM;

    REC_PLOT_DAT CUR_PLOT_DAT % ROWTYPE;

    L_EXT_AREA NUMBER: = 0;

    L_AREA NUMBER: = 0;

    BEGIN

    CUR_PLOT_DAT OPEN;

    LOOP

    EXTRACT THE CUR_PLOT_DAT IN L_EXT_AREA;

    WHEN THE OUTPUT CUR_PLOT_DAT % NOTFOUND;

    L_AREA: = L_EXT_AREA;

    END LOOP;

    CLOSE CUR_PLOT_DAT;

    RETURN (NVL(L_AREA,0));

    END XX_EXT;

    To view the track on one line...

    CREATE OR REPLACE FUNCTION XX_PLOT (P_ALOT_NUM NUMBER)

    RETURN VARCHAR2 IS

    CURSOR CUR_PLOT_DAT

    IS

    SELECT FIELD PEX

    OF XX_LINES_ALL

    WHERE LATEST_FLAG = 'Y '.

    AND ALOT_NUM = P_ALOT_NUM;

    REC_PLOT_DAT CUR_PLOT_DAT % ROWTYPE;

    L_SECTION VARCHAR2 (5000);

    L_PLOT VARCHAR2 (1000);

    BEGIN

    CUR_PLOT_DAT OPEN;

    LOOP

    EXTRACT THE CUR_PLOT_DAT IN REC_PLOT_DAT;

    WHEN THE OUTPUT CUR_PLOT_DAT % NOTFOUND;

    L_SECTION: = L_SECTION | REC_PLOT_DAT. PEX | «, » ;

    END LOOP;

    CLOSE CUR_PLOT_DAT;

    RETURN (NVL (L_SECTION,' '));

    END XX_PLOT;

    Please help me...

    Thanks in advance...

    for 11g:

    Select t1.alot_num, t1.name, sum (t2.ext), listagg (t2.plot) within the Group (order by rownum)

    of xx_all t1

    Join the t2 xx_lines_all

    On t1.alot_num = t2.alot_num

    -I forgot to group of

    T1.alot_num group, t1.name

    less than 11g watch "String aggregation"

    Re: 4. How can I convert rows to columns?

    ----

    Ramin Hashimzade

    Post edited by: Ramin Hashimzadeh

  • The same ID and Message of a group line

    ID MESSAGES
    1On the method of calculation error
    1T_RATE cannot be null
    2On the method of calculation error
    2Length is greater than 10

    ID MESSAGES
    1Error on the method of calculation, T_RATE cannot be null
    2Error on the method of calculation, the length was greater than 10

    How to group the same id and message together? Thank you

    Hello

    This is called String aggregation.  Here's a way to do it:

    SELECT id

    LISTAGG (messages, ",") THE Group (ORDER BY NULL) as messages

    FROM table_x

    GROUP BY id

    ;

    Other means, see

    ORACLE-BASE - String aggregation Techniques

  • help required on table transpose

    DATA IN THE TABLE:

    ST IC OC         

    I have 18 2

    20 4 K

    10 1 L

    where ST, IC and OC are names of columns and I want data from the table format below. Please help,

    I K L         

    IC 18 20 10

    OC       2    4      1

    Hello

    Visit these pages to learn how to rotate the data:

    http://forums.Oracle.com/forums/thread.jspa?MessageID=4347279�

    http://forums.Oracle.com/forums/thread.jspa?MessageID=3662005

    If you don't know not set an upper limit for the number of columns in the result, swing requires dynamic SQL and I recommend you rather use String aggregation , where the output is a column of the great string, format to watch as separate columns.

    If you get stuck, post your best attempt, as well as some examples of data (CREATE TABLE and only relevant columns, INSERT statements) and the desired results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the forum FAQ https://forums.oracle.com/message/9362002#9362002

  • LISTTAG functionlity in Oracle 10 G

    Hello world
    I use Oracle Database 10 g Enterprise Edition Release 10.2.0.1.0 - 64 bit.
    Please look at my request and help out me. Will it work for Oracle 10 g?
    SELECT WEST_TEST_ID, LISTAGG(WEST_TEST_CODE, ',')
    WITHIN GROUP (ORDER BY WEST_TEST_CODE) AS test_codes
    FROM test_code_conversion
    GROUP BY WEST_TEST_ID;
    The error I'm getting is ORA-00923 (From keyword not found)
    Kind regards
    BS2012.

    No, you must be on the version 11.2 of the database (and beyond) If you want to use LISTAGG.
    Other techniques can be found here:
    http://www.Oracle-base.com/articles/Misc/string-aggregation-techniques.php (try instead the STRAGG)

  • GROUP_CONCAT

    Hi all

    What is the equivalent of 'GROUP_CONCAT' in mysql to oracle?

    as in group_concat (emp_name) select from emp where dept_no = '10';

    output is 1 row: JUSTIN, HEMANT, BILLY, AMAN, SBT, ASAHI, BLU, ED, FRANK, RP, APC, WHOELSE


    Thank you

    asahide wrote:
    11g R1, you can use the wmsys.wm_concat function.
    But this func func undocumented...

    Kind regards

    and

    Alexandre Gelin says:
    Here's a simple example
    http://nimishgarg.blogspot.in/2010/02/Oracle-new-string-aggregation.html

    the two recommendations for use wm_concat are stupid.

    As mentioned, it is undocumented. This means that the mode of operation is not completely know we as developers. It also means that Oracle can change its operation in the different versions of the database, or they can even choose to get rid of the service overall, then you're going to have a broken application and Oracle are not required to support any application code that uses an undocumented feature.

    There are many examples of aggregation of the chain in the FAQ: {message identifier: = 9360005}
    including a link to where Tom Kyte says you shouldn't use wm_concat (and therefore it should not yet be recommended as an option by anyone)...
    {message: id = 9965699}

    Samir, he is also considered as a poor forum tag (and is frowned upon by the RTO admin that tighten the rules), to just post responds that the link to your own blog. It is enough just to link to your blog in support of an answer you gave on the forums, but the answer just directing people to your blog is close to being a bad use of the forums, and I think that I already warned you about this before, so please refrain from doing.

Maybe you are looking for