Multirows into single column

Hi People,
I use oracle 10g and forms,reports 6i.I have data as follows,
admno  course
100      MBBS
100      MS
my required o/p should be,
admno  course
100      MBBS,MSThat is not only for this particular data.for any given admission number of an employee if he has done more than one course it should appeared within a single line.is that possible using SQL query.kindly help me.
Regards
Vids
Edited by: vidusnat on Aug 18, 2011 9:34 PM

vidusnat wrote:
Hi People,
I use oracle 10g and forms,reports 6i.I have data as follows,
admno  course
100      MBBS
100      MS
my required o/p should be,
admno  course
100      MBBS,MSThat is not only for this particular data.for any given admission number of an employee if he has done more than one course it should appeared within a single line.is that possible using SQL query.kindly help me.
Regards
Vids
Edited by: vidusnat on Aug 18, 2011 9:34 PMLots of examples here.
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

Similar Messages

  • Convert different rows into single column

    DB : 11.1.0.7
    OS : Solaris Sparc 5.10
    I have one query which is joining few tables and giving me output like below.
    personnum orgnm
    ======= =======
    6     Keyholder
    9     Sales
    3     Mgmt
    I would like to convert that into single column like below.
    col1
    ========
    6,Keyholder,9,Sales,3,Mgmt
    I have tried with pivot and decode, but not getting resule which I am exepcting. Any suggesstions ?

    yashwanth437 wrote:
    listagg() function could work.LISTAGG is not available in 11.1. It was introduced in 11.2.
    Anyway, XML solution:
    with sample_table as (
                          select 6 personnum,'Keyholder' orgnm from dual union all
                          select 9,'Sales' from dual union all
                          select 3,'Mgmt' from dual
    select  rtrim(xmlagg(xmlelement(e,personnum || ',' || orgnm,',').extract('//text()')),',') col1
      from  sample_table
    COL1
    6,Keyholder,9,Sales,3,Mgmt
    SQL> SY.

  • How to Splilit The String Into Single Column using Comma As Delimiter ?

    How to Splilit The String Into Single Column using Comma As Delimiter ?
    using Function

    refer my thread ,code is also available see if that helps you
    error while executing the sp ORA-21779: duration not active

  • Concatenate multiple row values into single column value

    Hello,
    Can anyone please refresh my memory on how to concatenate multiple row values into a single column value.
    In the following query, I will get multiple denial reasons per application and I would rather return all denial reasons on one line.
    SELECT a.application_id, a.membership_number,
    r.reason_text AS denial_reason,
    a.appl_receipt_date AS application_receipt_date,
    a.plan_request_1 AS application_plan_code,
    a.adjudication_date AS application_denial_date
    FROM application a, PLAN p, application_reason ar, reason r
    WHERE a.plan_request_1 = p.plan_cd
    AND a.application_id = ar.application_id
    AND ar.reason_id = r.reason_id
    AND a.adjudication_cd = 'D'
    AND a.appl_receipt_date BETWEEN '01-jan-2006' AND '31-dec-2006'
    AND p.plan_type_id = 12 and a.application_id = :appId
    ORDER BY application_id
    Any help is greatly appreciated.
    Thanks,
    -Christine

    found the following
    SELECT deptno,
           LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
           KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
    FROM   (SELECT deptno,
                   ename,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
            FROM   emp)
    GROUP BY deptno
    CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
    START WITH curr = 1;
        DEPTNO EMPLOYEES
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    3 rows selected.at http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • Merging values of CKFs in two columns into single column

    Hi ,
    I want to merge values present in two different columns.The values present in rows of one column are not present in rows of other column, I have to merge the values into a single column.so that in the single column i can get all the values.how to do it in BEx.
    regards ,
    man.

    Hi,
    Dear murali , the solution you gave has helped me a bit as i am able to get the values for both the formula KF's in the same column,But another problem has arisen.
       For both the formula KF's I had to choose 'New Selection' (and not 'New formula')after R-cllick on the structure, as I had to use a Characteristic as restriction for Each of the KF's, and also to use the Characteristic I had to associate it with some KF so that the Characteristic wil be used as a KF in the formula.
       Now what is happening is that I am getting the values of that associated KF also in the empty rows.(i.e. the rows where the value of both the KF1 and KF2 is not present)
       What has to be done to remove them and keep the empty rows empty and not show the value of the KF taken with the Characteristic for restriction. Also its value is summing up with KF1 and KF2 in the coulmn which is having both KF1 and KF2 together.
    Regards
    man

  • Concat rows values into single column

    Hi All,
    How can I concat values of a multiple rows into a single column by separating them by comma.
    Eg:
    SELECT empno FROM emp;
    empno
    1
    2
    3
    4
    I want output should be:
    Empnos
    1,2,3,4
    Thanks & Regards,
    Danish

    MichaelS wrote:
    Or
    SQL>  select rtrim(xmlagg(xmlelement(e, empno || ',')).extract('//text()').extract('//text()') ,',') empnos from emp
    EMPNOS                                                                         
    7369,7499,7521,7566,7654,7698,7782,7788,7839,7844,7876,7900,7902,7934 
    Hi Michael,
    is it an error or is it correct to put extract 2 times? This is giving to me the same result:
    select rtrim(xmlagg(xmlelement(e, empno || ',')).extract('//text()'),',') empnos from emp;
    EMPNOS                                                                         
    7369,7499,7521,7566,7654,7698,7782,7788,7839,7844,7876,7900,7902,7934           Regards.
    Al

  • Merge multiple columns into single column?

    Hi,
    I need to execute queries dynamically and return the values. I need to fetch the values of the queries in single column only by concatenating the multiple columns. I cannot use PL/SQL in my scenario.
    is there any way to execute a query and the result will be fetched in single column (values of multiple columns needs to be concatenated)?
    Thanks,
    Raja.

    hi,
    do you mean this??
      1* select EMPNO||' '||ENAME||' '||JOB||' '||MGR||' '||HIREDATE||' '||SAL||' '||COMM||' '||DEPTNO||
    SQL> /
    MULTIPLE_COL
    100 JDF DIR  05-SEP-09 200 1000 10
    7497 MILLER CLERK 7782 23-JAN-82 25000 195 35
    7566 JONES MANAGER 7839 02-APR-81 3175 446.25 20
    7654 RAR SALESMAN 7698 28-SEP-81 1450 1587.5 30
    7698 BLAKE MANAGER 7839 01-MAY-81 3050 427.5 30
    7782 CLARK MANAGER 7839 09-JUN-81 2650 367.5 10
    7788 SCOTT ANALYST 7566 09-DEC-82 3200 450 20
    7839 KING PRESIDENT  17-NOV-81 5200 8250 10
    7844 TURNER SALESMAN 7698 08-SEP-81 1700 225 30
    7876 ADAMS CLERK 7788 12-JAN-83 1300 165 20
    7900 JAMES CLERK 7698 03-DEC-81 1150 85.5 30 [email protected]
    MULTIPLE_COL
    7902 FORD ANALYST 7566 03-DEC-81 3200 450 20
    8000 KINGBABA PRESIDENT  17-NOV-81 5200 8250 10
    8001 TURNER RAV SALESMAN 8000 08-SEP-81 1700 450 30
    1001 KITTU DOR  05-SEP-09 1200 100 40
    15 rows selected.Or
    Mean this??
    SQL> ed
    Wrote file afiedt.buf
      1  With T As
      2     ( Select Level col1 From dual Connect By Level<=10
      3     )
      4     Select Max(SYS_CONNECT_BY_PATH(COL1||',',' ')) Multi_col
      5       From
      6     ( Select COL1, Lag(COL1) Over (Order By COL1) As Lag
      7             From   T  )
      8      Start With Lag Is Null
      9        Connect By
    10*    Prior col1 = LAG
    SQL> /
    MULTI_COL
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,Edited by: user291283 on Sep 8, 2009 10:10 PM

  • Transform Multiple column into single column;

    Hi all,
    I have a table with multiple columns
    Col_1
    Col_2
    Col1_3
    Col_4
    Col_5
    Col1_6
    Col_7
    Col_8
    Col1_9
    Val_1
    val_2
    Val_3
    Val_4
    val_5
    Val_6
    Val_7
    val_8
    Val_9
    Oper1
    Oper2
    Oper9
    Currently the table look like this
    ID Name | f_actve | Col_1| Col_2|….Col1_9| Val_1| val_2| …Val_9| Oper1…..| Oper9
    Now I need to insert the data into new table The structure of the new table look like this
    Table : T1 (header)
    ID | Name | F_active
    Table : T2 (detail )
    Dtl ID |  Columnname | Oper
    Now all the column_name Col_1through Col_9 should be inserted into column_name column.
    Same thing with the Opers
    Table T3(detail )
    DTL_ID | Column_Values
    Now all the Column_Values Col_1through Col_9 should be inserted into column_name column
    Please help
    We have 10G /11g.
    Thanks
    Rebecca

    What you are trying to do is called unpivot in 11g.
    See this example.
    SQL> WITH T
      2       AS (SELECT 1 dtl_id,
      3                  1 col1,
      4                  2 col2,
      5                  3 col3,
      6                  4 col4
      7             FROM DUAL)
      8  SELECT * FROM T;
        DTL_ID       COL1       COL2       COL3       COL4
             1          1          2          3          4
    SQL> WITH T
      2       AS (SELECT 1 dtl_id,
      3                  1 col1,
      4                  2 col2,
      5                  3 col3,
      6                  4 col4
      7             FROM DUAL)
      8  SELECT dtl_id, "COL_VALUES"
      9    FROM T UNPIVOT (col_values FOR abc IN (col1, col2, col3, col4));
        DTL_ID COL_VALUES
             1          1
             1          2
             1          3
             1          4
    SQL>

  • Converting multiple column rows into single column

    Hi all Below is my requirement, can you anybody help me solve it. CREATE TABLE TYPE (   c1_type  VARCHAR2 (10),   c2_type  VARCHAR2 (10),   c3_type  VARCHAR2 (10),   c4_type  VARCHAR2 (10),   c5_type  VARCHAR2 (10),   c6_type  VARCHAR2 (10),   c7_type  VARCHAR2 (10),   c8_type  VARCHAR2 (10),   c9_type  VARCHAR2 (10)); INSERT INTO TYPE     VALUES ('Region_D',             'Region_E',             'Region_F',             'Region_D',             'Region_E',             'Region_D',             'Region_M',             'Region_D',             'Region_E'); commit; Acutal output on the below query select * from type; C1_TYPE C2_TYPE C3_TYPE C4_TYPE C5_TYPE C6_TYPE C7_TYPE C8_TYPE C9_TYPE Region_D Region_E Region_F Region_D Region_E Region_D Region_M Region_D Region_E Acutal i am expecting the below output,how to make it using query or using oracle built in function. Region_D Region_D Region_D Region_D Region_E Region_E Region_E Region_F Region_M

    Hi,
    So, you want to put the column values in alphabetic order, with the earliest value in c1_type and the last in c9_type, is that it?
    The fact that you even want to do this says that this is a bad table design.  If sorting the values makes sense, then putting them all in the same column on 9 different rows (rather than 9 different columns on 1 row) makes sense.
    If you're stuck with the current design, then use SELECT ... UNPIVOT to put them on separate rows, then use the analytic ROW_NUMBER function to assign numbers 1-9 to each value, and finally use SELECT ... PIVOT to put them back into 1 row in that order.  If you're not familiar with the built-in UNPIVOT and PIVOT features, look them up in the SQL Language manual, and see the forum FAQ:
    https://forums.oracle.com/message/9362005
    If you get stuck, post your best attempt (formatted), the exact results you want (formatted), and your Oracle version (e.g. 11.2.0.2.0).
    Also, TYPE is an Oracle keyword, so it's not a good table name.  Use something like location_type instead.

  • Convert Rows  into single column

    Hi,
    My employee details table has data like below,
    employee_id position department
    100 technician 50
    100 IT 80
    101 Accountant 60
    101 Accounting Manager 70
    Now i want to covert the rows into column. So my output should be like this.
    output:
    employee_id position department position1 department1
    100 technician 50 IT 80
    101 Accountant 60 Accounting Manager 70
    Help me on this
    Edited by: Vi on Mar 22, 2012 5:36 AM
    Edited by: Vi on Mar 22, 2012 5:36 AM

    Igor.M wrote:
    http:// website link removed /t_converting_rows_columns.htm
    Please don't post links to commercial websites that are only trying to sell their products and services. It breaches the terms of use of the forums.
    There are usually more suitable websites giving much more valuable information without all the self promotion (google adwords etc. are acceptable), or in the case of this particular question there is a FAQ post that relates to it...
    {message:id=9360005}

  • How to convert rows into single columns in Oracle?

    I have table with data like shown below in Oracle database.
    P_COLUMN
    COLUMN_1
    COLUMN_2
    COLUMN_3
    COLUMN_ 4
    COLUMN_5
    COLUMN_6
    COLUMN_7
    COLUMN_8
    COLUMN_9
    COLUMN_10
    1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    1
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    1
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    2
    AA1
    AA2
    AA3
    AA4
    AA5
    AA6
    AA7
    AA8
    AA9
    AA10
    2
    BB1
    BB2
    BB3
    BB4
    BB5
    BB6
    BB7
    BB8
    BB9
    BB10
    I need a query to get one row based on P_COLUMN's value i.e. for P_COLUMN =1, below should be output :-
    C_1
    C_2
    C_3
    C_4
    C_5
    C_6
    C_7
    C_8
    C_9
    C_10
    C_11
    C_12
    C_13
    C_14
    C_15
    C_16
    C_17
    C_18
    C_19
    C_20
    C_21
    C_22
    C_23
    C_24
    C_25
    C_26
    C_27
    C_ 28
    C_29
    C_30
    C_31
    1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    2
    AA1
    AA2
    AA3
    AA4
    AA5
    AA6
    AA7
    AA8
    AA9
    AA10
    BB1
    BB2
    BB3
    BB4
    BB5
    BB6
    BB7
    BB8
    BB9
    BB10
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    i searched google and found PIVOT, CROSS JOIN etc but could not use those keyword properly.
    Thanks in advance.
    Note - My DB client version is 11g.

    Since you have 11G, here's an alternative with the PIVOT clause.
    First, set up test data with up to 10 rows:
    CREATE TABLE T(P1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10) AS SELECT
    1,1,2,3,4,5,6,7,8,9,10 FROM DUAL;
    INSERT INTO T
    WITH DATA AS (SELECT LEVEL*10 N FROM DUAL CONNECT BY LEVEL <= 9)
    SELECT P1, C1+N, C2+N, C3+N, C4+N, C5+N, C6+N, C7+N, C8+N, C9+N, C10+N
    FROM T, DATA;
    INSERT INTO T
    SELECT P1+1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
    FROM T
    WHERE C1 <= 11;
    select * from t order by p1,c1;
    P1
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    1
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    1
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    1
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    1
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    1
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    1
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    1
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    1
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    1
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    2
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    Now the SELECT statement using PIVOT:
    SELECT * FROM (
      SELECT T.*,
      ROW_NUMBER() OVER (
        PARTITION BY P1
        ORDER BY C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
      ) RN
      FROM T
    PIVOT(
      MAX(C1) C1, MAX(C2) C2, MAX(C3) C3, MAX(C4) C4, MAX(C5) C5,
      MAX(C6) C6, MAX(C7) C7, MAX(C8) C8, MAX(C9) C9, MAX(C10) C10
      FOR RN IN (1 R1,2 R2,3 R3,4 R4,5 R5,6 R6,7 R7,8 R8,9 R9,10 R10)
    P1
    R1_C1
    R1_C2
    R1_C3
    R1_C4
    R1_C5
    R1_C6
    R1_C7
    R1_C8
    R1_C9
    R1_C10
    R2_C1
    R2_C2
    R2_C3
    R2_C4
    R2_C5
    R2_C6
    R2_C7
    R2_C8
    R2_C9
    R2_C10
    R3_C1
    R3_C2
    R3_C3
    R3_C4
    R3_C5
    R3_C6
    R3_C7
    R3_C8
    R3_C9
    R3_C10
    R4_C1
    R4_C2
    R4_C3
    R4_C4
    R4_C5
    R4_C6
    R4_C7
    R4_C8
    R4_C9
    R4_C10
    R5_C1
    R5_C2
    R5_C3
    R5_C4
    R5_C5
    R5_C6
    R5_C7
    R5_C8
    R5_C9
    R5_C10
    R6_C1
    R6_C2
    R6_C3
    R6_C4
    R6_C5
    R6_C6
    R6_C7
    R6_C8
    R6_C9
    R6_C10
    R7_C1
    R7_C2
    R7_C3
    R7_C4
    R7_C5
    R7_C6
    R7_C7
    R7_C8
    R7_C9
    R7_C10
    R8_C1
    R8_C2
    R8_C3
    R8_C4
    R8_C5
    R8_C6
    R8_C7
    R8_C8
    R8_C9
    R8_C10
    R9_C1
    R9_C2
    R9_C3
    R9_C4
    R9_C5
    R9_C6
    R9_C7
    R9_C8
    R9_C9
    R9_C10
    R10_C1
    R10_C2
    R10_C3
    R10_C4
    R10_C5
    R10_C6
    R10_C7
    R10_C8
    R10_C9
    R10_C10
    1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

  • Collect Multiple Responses Into Single Column

    I need a form that can collect multiple names and phone numbers and save the data in two columns. One column for names and one column for phone numbers.
    How can I do this?

    My form looks like this:
    Name:
    Phone:
    Name:
    Phone:
    Name:
    Phone:
    So responses come in looking like this:
    Name:          Phone:                 Name:          Phone:             Name:          Phone:
    John             xxx-xxx-xxxx          Jane          xxx-xxx-xxxx          Paul          xxx-xxx-xxxx
    I need them to look like this:
    Name:          Phone:
    John          xxx-xxx-xxxx
    Jane          xxx-xxx-xxxx
    Paul          xxx-xxx-xxxx

  • Amount and Quantity (with curr and unit) into single column

    Hi All,
    I have a query with several measures in the rows and two columns, one with 0AMOUNT and the other with 0QUANTITY. At least one of them (0AMOUNT, 0QUANTITY) equals 0 and I'd like to have the query just one column with 0AMOUNT and if 0AMOUNT = 0, then to put there 0QUANTITY. So I used this formula :
    ( 'Amount' <> 0 ) * NODIM ( 'Amount' ) + ( 'Amount' == 0 ) * NODIM ( 'Quantity' )
    The problem is that I need to preserve 0UNIT and 0CURRENCY and if I remove NODIM the formula of course ends with error. Any idea how to solve this??
    Thanks for any suggestions.
    Pavel

    user9502062 wrote:
    i want to do this without using any predefined functions.Well this solution still uses an analytical function if that's allowed...
    SQL> ed
    Wrote file afiedt.buf
      1  select deptno
      2        ,rtrim(max(decode(rn,1,ename))||','||
      3         max(decode(rn,2,ename))||','||
      4         max(decode(rn,3,ename))||','||
      5         max(decode(rn,4,ename))||','||
      6         max(decode(rn,5,ename))||','||
      7         max(decode(rn,6,ename))||','||
      8         max(decode(rn,7,ename))||','||
      9         max(decode(rn,8,ename))||','||
    10         max(decode(rn,9,ename))||','||
    11         max(decode(rn,10,ename)),',') as enames
    12  from (select deptno, ename, row_number() over (partition by deptno order by ename) as rn from emp)
    13* group by deptno
    SQL> /
        DEPTNO ENAMES
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    SQL>... but it does limit you to how many rows you can join together.
    Otherwise I'd suggest you go back to your teacher and ask them for more information about why you can't use predefined functions.

  • SQL - Multiple Fetch into Single Column with Comma Separator

    Hello Experts,
    Good Day to all...
    I need your help on following scenarios. The below query returns set of titleID strings. Instead of printing them one below the other as query output, I want the output to be in batch of 25 values.i.e each row should have 25 values separated by comma. i.e If there are 100 titles satisfying the output, then there should be only four rows with and each row having 25 titles in comma separated manner.
    SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);I tried with the PL/SQL block; whereas it is printing all the values continously :(
    I need to stop with 25 values and display.
    If its possible with SQL block alone; then it would be of great help
    DECLARE
       v_str   VARCHAR2 (32767)  := NULL;
       CURSOR c1
       IS
         SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);
    BEGIN
       FOR i IN c1
       LOOP
          v_str := v_str || ',' || i.title_id;
       END LOOP;
       v_str := SUBSTR (v_str, 2);
       DBMS_OUTPUT.put_line (v_str);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Error-->' || SQLERRM);
    END;Thanks...

    You can use CEIL
    Sample code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                val,
                nt,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val)    AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev
            FROM
                    SELECT
                        level                          AS val,
                        ceil(rownum/3)  as nt /* Grouped in batches of 3 */
                    FROM
                        dual
                        CONNECT BY level <= 10
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;
            NT CONCAT_VAL
             1 1,2,3
             2 4,5,6
             3 7,8,9
             4 10Your code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                title_id,
                nt,
                ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id)   AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev
            FROM
                    SELECT
                        title_id,
                        ceil(rownum/25) AS nt /* Grouped in batches of 25 */
                    FROM
                        pack_relation tdpr
                    JOIN annotation fa
                    ON
                        tdpr.package_id = fa.package_id
                    GROUP BY
                        title_id,
                        fa.package_id
                    HAVING
                        COUNT (fa.package_id) < 500
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;

  • Rows into single column with comma seperator

    Hi Friends,
    I have the following Query
    select A.tradeid||','||A.TICKER||'|'||A.SUBORDINATION||'|'||A.CUSIP||'|'||A.DOCCLAUSE||'|'||A.CURRENCY from table A
    where A.ticker in ('LYME','GAADF') and A.tradeid in('456777')
    which is returning
    456777,LYME|SENIOR UNSECURED|Z1700990|MM|USD
    456777,GAADF|SENIOR UNSECURED|Z1246790|MM|USD
    I want the result set as:
    456777,LYME|SENIOR UNSECURED|Z1700990|MM|USD,456777,GAADF|SENIOR UNSECURED|Z1246790|MM|USD
    Please help me to get the result set
    Thanks,
    ragu.
    Edited by: user533548 on Apr 3, 2009 12:54 AM
    Edited by: user533548 on Apr 3, 2009 12:55 AM

    you could do
    select max (ltrim (sys_connect_by_path (tradeid||'|'||TICKER||'|'||SUBORDINATION||'|'||CUSIP||'|'||DOCCLAUSE||'|'||CURRENCY, ','), ','))
      from (
    select tradeid
         , ticker
         , subordination
         , cusip
         , docclause
         , currency
         , row_number() over (partition by tradeid
                                  order by null
                             ) rn
      from x)
    start with rn = 1
    connect by rn = prior rn + 1like in
    SQL> with x as
      2  (
      3  select 456777 tradeid ,'LYOE' ticker ,'SENIOR UNSECURED' subordination,'Z1830990' cusip,'MM' docclause,'USD'  currency from dual union all
      4  select 456777 tradeid ,'GAZDF','SENIOR UNSECURED','Z8446790','MM','USD' from dual
      5  )
      6  select max (
      7        ltrim
      8        (sys_connect_by_path (tradeid||'|'||TICKER||'|'||SUBORDINATION||'|'||CUSIP||'|'||DOCCLAUSE||'|'||CURRENCY
      9         , ',')
    10        , ',')) str
    11    from (
    12  select tradeid
    13       , ticker
    14       , subordination
    15       , cusip
    16       , docclause
    17       , currency
    18       , row_number() over (partition by tradeid
    19                                order by null
    20                           ) rn
    21    from x)
    22   start with rn = 1
    23   connect by rn = prior rn + 1
    24 
    SQL> /
    STR
    456777|GAZDF|SENIOR UNSECURED|Z8446790|MM|USD,456777|LYOE|SENIOR UNSECURED|Z1830990|MM|USD

Maybe you are looking for

  • Data services with SQL Server 2008 and Invalid time format variable

    Hi all Recently we have switched from DI on SQL Server 2005, to DS(Date Services) on SQL Server 2008. However I have faced an odd error on the query that I was running successfully in DI. I validate my query output using a validation object to fill e

  • Begin f(p= :1 ); commit; end;

    I was doing some tuning of my Oracle instance running Apex this morning, and the above text is the top by elapsed time, CPU time, and user wait time (with ~4500 executions in the past three days). It's not my SQL. By the look of it, it's probably a c

  • WD Ext. Hard Drive icon won't go away in Menu Bar?

    First, I tried Time Machine and it said I had to reformat my WD, but I didn't want to do that because it had my PC laptop saved to it. So, then I opened WD in Finder and tried to start the process through WD's software. It Scanned and started Process

  • How to put constraint??

    hi, 1st case i have a table ABC , in this i have 3 columns col1 col2 col3 now i want to put constraint on table level that col1 n col2 always b unique together like col1 col2 col3 100 1 item 100 2 item 100 3 item 200 1 item 200 2 item 2nd case i have

  • What version of windows can i install?

    i am looking to install windows on my mac, however i only have 80GB left on my hard drive, i am aware that vista will have no problems installing but this uses 20GB minimum, and i believe XP only uses 5GB minimum of hard drive. the trouble i am havin