Combine multiple rows into single value

I have the following results -
id staff
001 Joe
001 Jim
001 Dave
002 Kim
002 Pat
002 Alan
003 Peter
004 Mick
004 Paddy
005 Steve
005 Eric
I want to have the results displayed as follows -
id staff
001 Joe,Jim,Dave
002 Kim,Pat,Alan
003 Peter
004 Mick,Paddy
005 Steve, Eric
I have had a play about with this sort of thing before and I think SYS_CONNECT_BY_PATH will need to be used? Not really 100% sure though.
All help will be appreciated.
Cheers.

Having a bit of trouble getting these solutions to work.
Heres another example to try and show what my problem is...
I have a table with the following -
Region Country_name
Britain England
Britain Scotland
Britain Wales
Europe Spain
Europe Italy
Europe France
Running the following Script...
SELECT distinct region, SUBSTR (SYS_CONNECT_BY_PATH (country_name , ','), 2) csv
FROM (SELECT region, country_name , ROW_NUMBER () OVER (partition by region ORDER BY region ) rn,
COUNT (*) OVER (partition by region ) cnt
FROM countries)
WHERE rn = cnt
START WITH rn = 1
CONNECT BY rn = PRIOR rn + 1;
I get the results ...
Britain      England,Italy,Scotland
Europe      England,Italy,France
Britain      England,Wales,Scotland
Britain      Spain,Wales,Scotland
Europe      Spain,Italy,France
Britain      Spain,Italy,Scotland
Europe      England,Wales,France
Europe      Spain,Wales,France
Which is clearly wrong, I want
Britain      England,Italy,Scotland
Europe Spain,Italy,France
and thats all!

Similar Messages

  • Combining Multiple Rows into single row with multple columns

    Hi Experts,
    I have the following requirement, kindly help me.
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.
    ID NAME DEPT1 DEPT2 DEPT3
    1 Sam 10 20
    2 alex 30 40 50
    3 vinod 60 70
    It's urgent requirement, kindly help me.
    Thanks in advance.

    Right I've had my drink, so what was this "urgent" question then?
    798616 wrote:
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.Dynamic numbers of columns eh! Tricky.
    If you understand how SQL statements are executed it's along these lines...
    1. Open Cursor
    2. Parse SQL statement and determine columns
    3. Bind in any input values
    4. Fetch data
    5. Bind out values to columns
    6. Repeat step 3 until no more data
    7. Close cursor
    Now, you're expecting that you can determine the columns (step 2) from the fetched data (step 4 onwards). You can't. The SQL engine needs to know the expected columns before any data is fetched so, it can't base the number of columns on the data itself.
    If you need that requirement, you would need to query the data first and build up a dynamic query based on the data and then execute that dynamically built query to fetch the data and pivot it into those columns, which means that you have queried the data twice. Not good practice and not good (or simple) coding.
    What you're talking of doing is something that should be handled at the presentation/interface layer, not as part of the data fetch.
    Typically these sorts of things are handled most easily in report generation/writer tools such as Oracle Reports, Business Objects etc. where they fetch the data from the database and then process it to format it on the display, pivoting the results as required.
    It's not something that lends itself to be easily achieved in SQL. Yes, SQL can do pivoting of data quite easily, but NOT with a dynamic number of columns.
    If you were to specify that there is a maximum number of columns that you could get (rather than wanting it dynamic), then you can do it simply in SQL with the max-decode method...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select deptno, ename, row_number() over (partition by deptno order by ename) as rn from emp)
      2  --
      3  select deptno
      4        ,max(decode(rn,1,ename)) as ename1
      5        ,max(decode(rn,2,ename)) as ename2
      6        ,max(decode(rn,3,ename)) as ename3
      7        ,max(decode(rn,4,ename)) as ename4
      8        ,max(decode(rn,5,ename)) as ename5
      9        ,max(decode(rn,6,ename)) as ename6
    10        ,max(decode(rn,7,ename)) as ename7
    11        ,max(decode(rn,8,ename)) as ename8
    12        ,max(decode(rn,9,ename)) as ename9
    13        ,max(decode(rn,10,ename)) as ename10
    14  from t
    15  group by deptno
    16* order by deptno
    SQL> /
        DEPTNO ENAME1     ENAME2     ENAME3     ENAME4     ENAME5     ENAME6     ENAME7     ENAME8     ENAME9     ENAME10
            10 CLARK      KING       MILLER
            20 ADAMS      FORD       JONES      SCOTT      SMITH
            30 ALLEN      BLAKE      JAMES      MARTIN     TURNER     WARD
    SQL>

  • HOW TO COMBINE MULTIPLE ROWS INTO SINGLE ROWS

    Hi,
    I have a table with the following data:
    CASE-1
    TABLE -X
    RNO      FROM_SQN     TO_SQN     DATE
    ==========================================
    991      9           11     2010-01-01
    991      11           22     2010-01-01
    991      22           33     2010-01-01
    992      33           44     2010-01-01
    I want to see the result data as follows:
    RNO      FROM_SQN     TO_SQN     DATE
    ==========================================
    991      9           44     2010-01-01
    CASE-2
    TABLE -X
    RNO      FROM_SQN     TO_SQN     DATE
    ==========================================
    991      9           11     2010-01-01
    991      15           22     2010-01-01
    991      22           34     2010-01-01
    992      33           44     2010-01-01
    I want to see the result data as follows:
    RNO      FROM_SQN     TO_SQN     DATE
    ==========================================
    991      9           11     2010-01-01
    991      15           44     2010-01-01
    Please help me how to achieve this using SQL.
    Edited by: 986725 on Feb 7, 2013 2:36 AM

    with x as
    select 991 rno, 9 from_sqn ,11 to_sqn ,to_date('2010-01-01','yyyy-mm-dd') dt
    from dual union all
    select 991, 15 ,22 ,to_date('2010-01-01','yyyy-mm-dd') from dual union all
    select 991, 22 ,33 ,to_date('2010-01-01','yyyy-mm-dd') from dual union all
    select 991, 33 ,44 ,to_date('2010-01-01','yyyy-mm-dd') from dual
    x_with_group as
    select rno,from_sqn,to_sqn,dt,
           sum(sm) over(partition by rno,dt order by from_sqn) sm
    from
      select rno,from_sqn,to_sqn,dt,
             from_sqn-
              nvl(lag(to_sqn) over(partition by rno,dt order by from_sqn),0) sm
      from x
    select rno,min(from_sqn) from_sqn,max(to_sqn) to_sqn,dt
    from x_with_group
    group by rno,dt,sm
    order by rno,dt,from_sqn;
    RNO FROM_SQN TO_SQN DT       
    991        9     11 01-jan-2010
    991       15     44 01-jan-2010 Edited by: jeneesh on Feb 7, 2013 4:59 PM
    Assumed the date values are actually DATE types.
    Partition on DT and RNO can be amended as per your requirement..
    And assumed your sample data has a typo..
    If your data is correct..
    with x as
    select 991 rno, 9 from_sqn ,11 to_sqn ,to_date('2010-01-01','yyyy-mm-dd') dt
    from dual union all
    select 991, 15 ,22 ,to_date('2010-01-01','yyyy-mm-dd') from dual union all
    select 991, 22 ,33 ,to_date('2010-01-01','yyyy-mm-dd') from dual union all
    select 992, 33 ,44 ,to_date('2010-01-01','yyyy-mm-dd') from dual
    x_with_group as
    select rno,from_sqn,to_sqn,dt,
           sum(sm) over(order by from_sqn) sm
    from
      select rno,from_sqn,to_sqn,dt,
             from_sqn-
              nvl(lag(to_sqn) over(order by from_sqn),0) sm
      from x
    select min(rno) rno,min(from_sqn) from_sqn,max(to_sqn) to_sqn,min(dt) dt
    from x_with_group
    group by sm
    order by rno,dt,from_sqn;
    RNO FROM_SQN TO_SQN DT       
    991        9     11 01-jan-2010
    991       15     44 01-jan-2010 Edited by: jeneesh on Feb 7, 2013 5:14 PM

  • Combine multiple rows in single row

    I am new to SQL server and i am trying to combine multiple row in single row but i am not able to do it.Can anyone help me out?
    Input :
    Id |RED |BUY |BSW
    1328 NULL NULL 0.05
    1328 NULL 0.06 NULL
    1328 0.01 NULL NULL
    1328 0.05 NULL NULL
    1329 NULL NULL 0.05
    1329 NULL 0.05 NULL
    1329 0.05 NULL NULL
    Output
    Id |RED |BUY |BSW
    1328 0.01 0.06 0.05
    1328 0.05 NULL NULL
    1329 0.05 0.05 0.05

    Actually I am consolidating above result into text file and sending it to external system.Main aim is to remove NULL values and arrange the data as expected output.
    Also expected output can be
    Id         |RED   
    |BUY    |BSW
    1328        0.05   
    0.06    0.05
    1328        0.01   
    NULL    NULL
    Or
    Id         |RED   
    |BUY    |BSW
    1328        0.01   
    0.06    0.05
    1328        0.05   
    NULL    NULL
    for Id= 1328.

  • Multiple Row into single Row

    Hi friends,
    I have one table like:
    10 SAM
    10 CAN
    10 MAN
    10 DEV
    20 MAL
    And want output like:
    10 SAM,CAN,MAN,DEV
    20 MAL
    i want to combine multiple rows into one within an existing view.
    What query will suit this to get this type of output.

    Please refer to this thread
    column values separated by ,

  • Convert  multiple rows into single rows for the respective index name

    Dear Experts,
                             I want to convert  multiple rows into single rows for the respective index name,
                            Here is my query.
    SELECT user_tables.table_name, user_indexes.index_name, user_ind_columns.column_name
    FROM user_tables
    JOIN user_indexes on user_indexes.table_name = user_tables.table_name
    join USER_IND_COLUMNS on USER_INDEXES.INDEX_NAME = USER_IND_COLUMNS.INDEX_NAME
    where user_indexes.index_name not like '%PK%' AND user_ind_columns.column_name NOT LIKE '%SYS%'
    ORDER BY user_tables.table_name,user_indexes.index_name;
    Result of previous query
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE
    T1
    IDX_ACCTTYPCFG1
    ACC_CODE
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    MOBILE_NO
    T3
    IDX_ACTLG1
    ID
    Desired output required is
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCNTYPCFG1
    ENABLE_SERVICE,ACC_CODE,ACCTYPE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    please help.

    Maybe
    with
    user_tables as
    (select 'T1' table_name,'IDX_ACCNTYPCFG1' index_name,'ENABLE_SERVICE' column_name from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACC_CODE' from dual union all
    select 'T1','IDX_ACCTTYPCFG1','ACCTYPE' from dual union all
    select 'T2','IDX_ACCTTYPCFGAPP1','ACCTYPE' from dual union all
    select 'T3','IDX_ACTLG1','MOBILE_NO' from dual union all
    select 'T3','IDX_ACTLG1','ID' from dual
    select table_name,
           case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end index_name,
           listagg(case column_name when 'ID' then 'ACCTYPE' else column_name end,',') within group (order by null) column_name
      from user_tables
    group by table_name,case index_name when 'IDX_ACCNTYPCFG1' then 'IDX_ACCTTYPCFG1' else index_name end
    TABLE_NAME
    INDEX_NAME
    COLUMN_NAME
    T1
    IDX_ACCTTYPCFG1
    ACCTYPE,ACC_CODE,ENABLE_SERVICE
    T2
    IDX_ACCTTYPCFGAPP1
    ACCTYPE
    T3
    IDX_ACTLG1
    ACCTYPE,MOBILE_NO
    Regards
    Etbin

  • Merge multiple rows into single row (but multiple columns)

    How to merge multiple rows into single row (but multiple columns) efficiently.
    For example
    IDVal IDDesc IdNum Id_Information_Type Attribute_1 Attribute_2 Attribute_3 Attribute_4 Attribute_5
    23 asdc 1 Location USA NM ABQ Four Seasons 87106
    23 asdc 1 Stats 2300 91.7 8.2 85432
    23 asdc 1 Audit 1996 June 17 1200
    65 affc 2 Location USA TX AUS Hilton 92305
    65 affc 2 Stats 5510 42.7 46 9999
    65 affc 2 Audit 1996 July 172 1100
    where different attributes mean different thing for each Information_type.
    For example for Information_Type=Location
    Attribute_1 means Country
    Attribute_2 means State and so on.
    For example for Information_Type=Stats
    Attribute_1 means Population
    Attribute_2 means American Ethnicity percentage and so on.
    I want to create a view that shows like below:
    IDVal IDDesc IDNum Country State City Hotel ZipCode Population American% Other% Area Audit Year AuditMonth Audit Type AuditTime
    23 asdc 1 USA NM ABQ FourSeasons 87106 2300 91.7 46 85432 1996 June 17 1200
    65 affc 2 USA TX AUS Hilton 92305 5510 42.7 46 9999 1996 July 172 1100
    Thanks

    Hi,
    That's called Pivoting . The forum FAQ has a section on this subject: {message:id=9360005}
    I hope this answers your question.
    If not, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data. (You did post the results you wanted, but they're very hard to read because they're not formatted. Use \ tags, as described in the forum FAQ, below.)
    Explain, using specific examples, how you get the results you want from the data given.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).  This is always important, but especially so with pivots.
    See the forum FAQ {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • To Combine Multiple STOu2019s into Single Delivery

    Hi,
    What are the configuration settings to be done to combine multiple STOu2019s into one single delivery in VL10B. 
    My requirement is to combine multiple STOu2019s contains different DELIVERY DATES and having SAME SUPPLYING AND RECEIVING PLANT into one single delivery.
    Thanks & Regards,
    Victor.

    Hi
    Delivery in STO is created for single order and for same delivery date, same delivery no. for different delivery date and  for multiple STO is not possible and its not logically correct,since after creation of delivery you will be doing picking and packing and Goods Issue.
    Please check
    Kishor

  • ALV - Multiple Rows into Single Row

    I have a requirement to display the ALV output from CDHDR&CDPOS tables here in the output i have 15 columns( Fields ) any changes im displaying in report output ,but if there is same time multiple columns will change im displaying as individual record instead of that i need to show as single row.
    in this output last three records have same time change but i have populated into three different columns i want to make it as SINGLE Row Record.
    Thanks!!

    We don't need script task for this. Use TSQL in the datasource. Refer below example
    DECLARE @TEMP TABLE(ID INT, [VALUE] NVARCHAR(30))
    INSERT INTO @TEMP VALUES(1 , 'MAZ')
    INSERT INTO @TEMP VALUES(1 , 'HON')
    INSERT INTO @TEMP VALUES(1 , 'FOR')
    INSERT INTO @TEMP VALUES(2 , 'JEEP')
    INSERT INTO @TEMP VALUES(2 , 'CHE')
    INSERT INTO @TEMP VALUES(3 , 'NIS')
    INSERT INTO @TEMP VALUES(4 , 'GMC')
    INSERT INTO @TEMP VALUES(4 , 'ACC')
    INSERT INTO @TEMP VALUES(4 , 'LEX')
    SELECT [id],
    Stuff((SELECT ',' + [VALUE]
    FROM @TEMP
    WHERE [id] = a.[id]
    FOR xml path('')), 1, 1, '') [VALUE]
    FROM @TEMP a
    GROUP BY [id]
    Regards, RSingh

  • Multiple rows into single pipe delimited row ........

    Hi All
    I have the following data in multiple columns which needs to be converted into single pipedelimited row.
    Followinf is the example:
    DEPTNO ENAME
    ===== =====
    10 A
    10 B
    10 C
    Now my requirement is in output i should be able to display A|B|C|.........
    Note : The number of rows for any DEPTNO are not constant.
    Thanks,
    kalyan Kumar P

    Hi,
    I tried but it is not throwing error that "Invalid Identifier" and moreover you told it is undocumentes
    please tell me what i need to do to to make "wm_concat" work.If there is any alternate also please let me know.In your database WMSYS user is not created that is why you are not getting 'wm_concat' function.
    Create WM_CONCAT function with this
    CREATE OR REPLACE TYPE BODY wm_concat
    IS
       STATIC FUNCTION odciaggregateinitialize (sctx IN OUT wm_concat)
          RETURN number
       IS
       BEGIN
          sctx :=   wm_concat (NULL);
          RETURN odciconst.success;
       END;
       MEMBER FUNCTION odciaggregateiterate (self IN OUT wm_concat, p1 IN varchar2)
          RETURN number
       IS
       BEGIN
          IF (curr_str IS NOT NULL)
          THEN
             curr_str :=   curr_str || ' , ' || p1;
          ELSE
             curr_str :=   p1;
          END IF;
          RETURN odciconst.success;
       END;
       MEMBER FUNCTION odciaggregateterminate (self IN wm_concat, returnvalue OUT varchar2, flags IN number)
          RETURN number
       IS
       BEGIN
          returnvalue :=   curr_str;
          RETURN odciconst.success;
       END;
       MEMBER FUNCTION odciaggregatemerge (self IN OUT wm_concat, sctx2 IN wm_concat)
          RETURN number
       IS
       BEGIN
          IF (sctx2.curr_str IS NOT NULL)
          THEN
             self.curr_str :=   self.curr_str || ' , ' || sctx2.curr_str;
          END IF;
          RETURN odciconst.success;
       END;
    END;
    CREATE OR REPLACE FUNCTION wm_concat (p1 varchar2)
       RETURN varchar2
       AGGREGATE USING wm_concat;
       After creating this function try this query
    SELECT REPLACE (wm_concat (ename), ',', '|') ename FROM emp;Let me know if problem persist.
    Regards,
    Mahesh Kaila

  • Concatenation Multiple Rows into Single Row

    My select query is like wise
    ID Name
    1 Arthi
    2 Preethi
    3 Madhu
    4 Saranya
    Above i listed all the names using the select query. Now i have to combine this 4 rows in single row like
    Arthi,Preethi,Madhu,Saranya.
    Also this rows may be 5 or 50 too. So what are Names listed using select statement those should combine into one Single String.
    Help me pl

    Please post this in an appropriate forum;
    SQL and PL/SQL
    PL/SQL
    Community Feedback and Suggestions (Do Not Post Product-Related Questions Here)
    Adith

  • Multiple Rows into single IDoc in LSMW

    Hi.
    I am using on_change_transfer_record for header record. have succesfully done this for header and item segment level records.
    but not able to done the same at IDoc control record level.
    My problem is, Multiple IDocs are created for single record. There is no processing points available for IDoc control record to use on_change_trasfer_record.
    I want single IDoc for single record from multiple rows.
    Please help me out in this regard.
    Thanks
    Rajesh

    For u need to change the file format into the below structure.
    H,<filed1>,<filed2>,.........................
    I,<filed1>,<filed2>,.............................
    I,<filed1>,<filed2>,...........................
    I,<filed1>,<filed2>,.............................
    H,<filed1>,<filed2>,.............................
    I,<filed1>,<filed2>,................................
    sepcify an indicator "H" for header record, and "I" for item record.
    once u prepare the file as above.
    now in ur LSMW Source structure, declare a filed called "Identifier" both for header structure and Item structure as the first field.
    Specify the "Identifying field content" as "H" for header record and "I" for item record.
    Continue the remaining mapping as usual.
    Hope this helps.
    Edited by: Poorna Chandrasekhar on Mar 5, 2009 10:13 AM

  • Combine 2 rows into single row?

    I have a table A which has information related to a process. For process completion there exist 2 rows. One has in it the total elapsed time, the time the entire process (which is multipart) begin and end time, but the columns related to rows processed are blank. Another related row has a start, end and elapsed time in it -- which I don't want -- but it has the row counts that I do want.
    I want to take these 2 rows, combine the relevant information into 1 row and insert that row into table B.
    I know I could insert from the first row and then come back and update it from the second row, but I hate having to read Table A twice. Any suggestions?

    Hello
    Is it not just a matter of using group by with sum? I may well have missed an important detail but here's a starting point:
    SQL>    CREATE TABLE DT_TEST_PROCESS
      2  (  id                              number,
      3     stage                   number,
      4     rows_processed  number,
      5     elapsed                 number
      6  )
      7  /
    Table created.
    SQL>
    SQL> INSERT INTO dt_test_process
      2  VALUES(1,1,100,0)
      3  /
    1 row created.
    SQL> INSERT INTO dt_test_process
      2  VALUES(1,2,0,10)
      3  /
    1 row created.
    SQL> INSERT INTO dt_test_process
      2  VALUES(2,1,1000,0)
      3  /
    1 row created.
    SQL> INSERT INTO dt_test_process
      2  VALUES(2,2,0,20)
      3  /
    1 row created.
    SQL>
    SQL> INSERT INTO dt_test_process
      2  VALUES(3,1,500,0)
      3  /
    1 row created.
    SQL> INSERT INTO dt_test_process
      2  VALUES(3,2,0,30)
      3  /
    1 row created.
    SQL>
    SQL> SELECT
      2     id,
      3     SUM(rows_processed) total_rows,
      4     SUM(elapsed) total_elapsed
      5  FROM
      6     dt_test_process
      7  GROUP BY
      8     id
      9  /
            ID TOTAL_ROWS TOTAL_ELAPSED
             1        100            10
             2       1000            20
             3        500            30
    SQL>
    SQL> CREATE TABLE dt_test_process_sum AS
      2  SELECT
      3     id,
      4     SUM(rows_processed) total_rows,
      5     SUM(elapsed) total_elapsed
      6  FROM
      7     dt_test_process
      8  GROUP BY
      9     id
    10  /
    Table created.HTH
    David

  • Concatenate multiple rows into single row

    Hi I need to concatenate multiple rows,
    these are the rows I have
    Name
    Rnk
    Northshore
    1
    F3
    2
    Borderline
    3
    Mattoon
    3
    Vinemane
    5
    Arizona
    5
    WestShore
    5
    Schumburg
    5
    Wilson
    5
    This is how I would like it to look
    Name
    Rnk
    Northshore
    1
    F3
    2
    Borderline,   Mattoon
    3
    Vinemane,   Arizona, WestShore, Schumburg, Wilson
    5
    Thanks
    LISA86

    I meant is there a way to do it without using a table?
    LISA86
    We have not used any extra table. Ok, Try the below:
    Select distinct
    names= REPLACE(
    Select a.Name as [data()]
    From YOURTABLENAME A
    Where A.Rnk = b.Rnk
    Order by a.Name
    FOR XML PATH ('') ), ' ', ',') ,Rnk
    From YOURTABLENAME B Order by Rnk

  • Combining multiple rows into a single row

    Hi all,
    I have a tricky situation in a HR select.
    Imagine I have a dataset as below, simplified of course.
    Name Start Date End date Job Title Salary
    Tom 01/01/07 02/03/08 Gopher £500
    Tom 03/03/08 jobsworth £600
    Rick 04/05/09 Painter £500
    Harry 02/06/07 02/06/08 Gardener £300
    Harry 03/06/08 03/06/09 Runner £200
    Harry 04/06/09 Cook £400
    now, I need to select from above and return 3 rows so it looks as below
    name start date enddate title salary start date enddate title salary start date enddate title salary etc etc
    tom 01/01/07 02/03/08 gopher £500 03/03/08 blah 600
    Rick 04/05/09 painter £500
    harry etc etc etc
    Now, I know how to select onto one row ok, asumming that each employee has a fixed number of roles but the problem is that each employee has a different number of jobs, one could have had 5 while another 50 and I do not know the maximum at this time.
    Anyone have any ideas on how to appraoch this?
    tia,
    dw
    Edited by: derrywriter on Oct 2, 2009 3:50 PM
    Edited by: derrywriter on Oct 2, 2009 3:54 PM

    Ideally this should be done in a suitable reporting tool.
    Standard SQL requires a deterministic number of columns to be known at parse time i.e. before the data is fetched it needs to know how many columns are being returned.
    If you know there is a fixed maximum to the number of columns that can be returned you can use one of the various pivot methods (search the forum) which differ depending on whether you're using 9i, 10g or 11g database.
    If you can't determine a maximum number of columns you're pretty much stuck, unless you want to write some clever interfacing to the oracle ODCI as demonstrated in this thread:
    How to pipeline a function with a dynamic number of columns?
    Personally, I believe such reporting styles should be reserved for reporting tools.

Maybe you are looking for

  • How to track the report calling from powerbuilder?

    Suppose I have a powerbuilder application myapp. there are many reports created with pb. There are 2 possible for pb report: datawindow get data from stored procedure datawindow get date with sql. myapp use a specific login mylogin to connect to syba

  • Message Mapping anomaly

    Hi XI Gurus, I have a problem regarding my mapping. The result of my AND statement is false and true (2 outputs because of context) based on the Display Queue. I'm passing the result of my AND statement to a CollapseContext function. When I perform D

  • Trial version to paid

    Need help switching from trial version of LR5 to paid subscription

  • While will my photoshop elements 5.0 no longer download photos from my Canon T2i camera?

    Just recently my Photoshop Elements 5.0 will not download from my Canon T2i camera. - It connects properly, finds and counts the photos on the card, but when I click on "get photos" to download the photos, I get an error message saying it cannot find

  • Airport Status Icon shows no connection - however connection is there

    Dear all - I experience a strange issue introduced with the last update on my G5IMac when applying the last updates of OS10.4.10. When being online (wireless) I loose the connection for a fraction of a second - then it comes back. However the airport