Multiple record in one row..

Hi experts,
I want to merge multiple row from same table into one row... is it possible? if so then how??
Regards,
SKP

Sure, it's possible
create table scott.a
as
select 1 a, 2 b from dual     
union all
select 3 a, 4 b from dual     
create table scott.b
(a number, b number, c number, d number)
insert into scott.b
select a1.a,a1.b,a2.a,a2.b from scott.a a1, scott.a a2
where a1.a = 1 and a2.a = 3
P.S. Sorry, at first misunderstood the task
Message was edited by:
Dmytro Dekhtyaryuk

Similar Messages

  • Multiple records in one row

    Hi all,
    I want to display all the party codes which have same party name,
    and I want to display all the party codes in one row separated by comma. is it possible?

    You can either use analytic functions + hierarchy or stragg (listagg if you are on 11.2) or undocumentd wm_concat. There are plenty examples on this forum. For example:
    select  deptno,
            ltrim(sys_connect_by_path(job,','),',') job_list
      from  (
             select  deptno,
                     job,
                     row_number() over(partition by deptno order by job) rn
               from  emp
      where connect_by_isleaf = 1
      start with rn = 1
      connect by deptno = prior deptno
             and rn = prior rn + 1
        DEPTNO JOB_LIST
            10 CLERK,MANAGER,PRESIDENT
            20 ANALYST,ANALYST,CLERK,CLERK,MANAGER
            30 CLERK,MANAGER,SALESMAN,SALESMAN,SALESMAN,SALESMAN
    select  deptno,
            rtrim(stragg(job || ','),',') job_list
      from  emp
      group by deptno
        DEPTNO JOB_LIST
            10 MANAGER,PRESIDENT,CLERK
            20 CLERK,ANALYST,CLERK,ANALYST,MANAGER
            30 SALESMAN,MANAGER,SALESMAN,SALESMAN,CLERK,SALESMAN
    select  deptno,
            wm_concat(job) job_list
      from  emp
      group by deptno
        DEPTNO JOB_LIST
            10 MANAGER,PRESIDENT,CLERK
            20 CLERK,ANALYST,CLERK,ANALYST,MANAGER
            30 SALESMAN,MANAGER,SALESMAN,SALESMAN,CLERK,SALESMANSY.

  • How to get multiple records in one row and different column

    Hi All,
    I am using oracle database 11g
    and i have a two tables table_1, table_2
    table_1 having columns
    emp_no
    first_name
    middle_name
    last_name
    email
    and table_2 having columns
    emp_no
    phone_type
    phone_number
    and having entires
    emp_no phone_type phone_number
    1001 MOB 9451421452
    1001 WEMG 235153654
    1001 EMG 652341536
    1002 MOB 9987526312
    1003 WEMG 5332621456
    1004 EMG 59612356
    Now i want the output of values with phone type as MOB or WEMG in a single row with different columns
    emp_no first_name middle_name last_name email mobile officeno
    1001 mark null k [email protected] 9451421452 235153654
    1002 john cena gary [email protected] 9987526312 null
    1003 dany null craig [email protected] null 5332621456
    1004 donald finn sian [email protected] null null
    can i have any inputs to achive this???
    Regards
    $sid

    Frank Kulash wrote:
    sonething like this:Frank, you missed aggregate function (pivot requires one). However main thing is it will cause ORA-01748:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k'last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
    SELECT     *
    FROM     table_1      t1
    JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    PIVOT     (    max(t2.phone_number)
         FOR  t2.phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
            FOR  t2.phone_type  IN  ( 'MOB'   AS mob
    ERROR at line 19:
    ORA-01748: only simple column names allowed hereYou need to:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k' last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
         table_3 as (
                     select  t1.emp_no,first_name,middle_name,last_name,email,
                             phone_type,phone_number
                       FROM     table_1      t1
                       LEFT JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    SELECT     *
    FROM     table_3
    PIVOT     (    max(phone_number)
         FOR  phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
        EMP_NO FIRST_ MIDD LAST_ EMAIL                     MOB       WEMG
          1004 donald finn sian  [email protected]
          1003 dany        craig [email protected] null            5332621456
          1001 mark        k     [email protected]      9451421452  235153654
          1002 john   cena gary  [email protected]    9987526312
    SQL>SY.

  • How to concatenate multiple records into one

    Hi everybody:
    I want to know if exist some way to concat multiple records into one without using cursors. For example, I have a table named "Authors" like this:
    Lan|Author
    English|Ernest Hemingway
    Spanish|Octavio Paz
    Spanish|Mario Vargas Llosa
    English|Sinclair Lewis
    Spanish|Gabriel García Márquez
    And I want to get this:
    Author
    Octavio Paz, Mario Vargas Llosa, Gabriel García Márquez
    I have worked with SQL Server and I can do something like this:
    CREATE FUNCTION dbo.MyConcat (@lan varchar(10))
    RETURNS varchar(5000) AS
    BEGIN
    declare @retvalue varchar(5000)
    set @retvalue=''
    select @retvalue = @retvalue + Author +',' from Authors where lan = @lan
    return substring(@retvalue,1,len(@retvalue)-1)
    END
    ie, do not use cursors to concatenate records. However, with ORACLE, I have to do someting like this.
    FUNCTION MyConcat(P_Lan IN VARCHAR2) RETURN VARCHAR2 IS
    v_ret VARCHAR2(4000);
    v_element VARCHAR2(4000);
    v_cursor sys_refcursor;
    BEGIN
    OPEN v_cursor FOR SELECT Author FROM Authors where Lan = P_Lan
    LOOP
    FETCH v_cursor INTO v_elemento;
    EXIT WHEN v_cursor%NOTFOUND;
    IF v_ret IS NULL THEN
    v_ret := v_element;
    ELSE
    v_ret := v_ret || ', ' || v_element;
    END IF;
    END LOOP;
    RETURN v_ret;
    END;
    Exist some other way to do this?
    Best Regards
    Jack

    Tks both for answer... I forgot to mention that I am using Oracle 10g. I read about LISTAGG() but this function is available for Oracle 11g release 2.
    I wil read about the other techniques than Hoek mention
    Best Regards.
    Jack

  • Concatenate multiple records into one single record

    Hello everyone,
    Can anyone guide me how to merge multiple records into one single record
    like......... I am getting the data in the file like
    aaaaa/bbbbbbb/ccccccccccc/dddddddddddd/eee
    ffffff/gggg/hhhhhhhhhhhhhh
    /123/4567/55555/99999999/kaoabfa/eee
    fffff/kkkkkkkk/llllllllllllllllllllllll
    when i use gui_upload I am getting the data into the internal table in the above format.
    My main intension is to split the record at / to multiple lines and dowload it into another file.
    What i am planning to do is... if the line does not start with / then i want to concatenate the multiple lines into single line and then split it into multiple records. Can anyone guide me how to achieve this.

    Yes, it should work.
    In my example
    Loop at itab.
    concatenate i_text itab into i_text.
    endloop.
    You change that loop for the loop of your internal table with the file records
    So if you have this three records
    'aaaa/bbb/ccc'
    '/dddd/efg'
    'hijk/lmn'
    i_text will look like this at the end
    'aaaa/bbb/ccc/dddd/efghijk/lmn'
    then in this part of the code
    split i_text at '/' into table itab2.
    itab2 will have the records looking like this
    aaaa
    bbb
    ccc
    dddd
    efghijk
    lmn'

  • HCM Processes and Forms - Create multiple records of one infotype (eg 0008)

    Dear all,
    I'm trying to create two new records in infotype 0008 (basic pay). Regarding it's time constraint 1 it should like the following:
    Before
    01.01.2010 - 31.12.9999 - 2000u20AC
    After
    01.01.2010 - 08.11.2010 - 2000u20AC
    09.11.2010 - 31.12.2010 - 2500u20AC
    01.01.2010 - 31.12.9999 - 3000u20AC
    So I want to add two splits two the record. One is easy, as it's done by the SAP_PA operation. I experimented with the record indices and duplicating my fields, but it didn't work. Another idea would be to retriggerd the SAP_PA several times using scenario steps.
    Can you give me a hint, by which lever multiplee splits can be achieved? Or is this not possible at all?
    Thanks in advance,
    Peter

    Thanks for your fast reply.
    Knowing this as a fallback is comforting. I just want to ensure, that I don't apply any coding, if a task is also possible by customizing.
    Another idea I had in the meantime was to execute the SAP_PA several times. Do you have any experience, if this works to create multiple records in one infotype?
    Edited by: Peter Gilberg on Nov 9, 2010 2:34 PM

  • Update multiple records on one page php/mysql

    Hi folks,
    I am trying to adapt a page to offer the option to update multiple records on one page.
    The intention is to edit FAQ categories which are contained in a table with just two fields - the category and an id.
    The page lists each categories in a form with a submit button which is then repeated for each record in the recordset.
    Unfortunately my plan didn't work and only the first record updates as intended.
    Can anyone suggest how I can make it work?
    Here's the code I have so far.
    ************** The Update Code *****************
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if (!isset($mm_abort_edit) || !$mm_abort_edit) {
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE faq_categories SET category=%s WHERE id=%s",
                           GetSQLValueString($_POST['category'], "text"),
                           GetSQLValueString($_POST['id'], "int"));
      mysql_select_db($database_con_mysite, $con_mysite);
      $Result1 = mysql_query($updateSQL, $con_mysite) or die(mysql_error());
      $updateGoTo = "faq-category-edit.php
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    ************** Update Code Ends *****************
    ************** The Form *****************
    <form name="frm_editcategory" id="frm_editcategory" method="POST" action="<?php echo $editFormAction; ?>">
      <?php do { ?>
    <fieldset>
              <input name="id" type="hidden" value="<?php echo $row_rs_faqcategory['id']; ?>" />
              <input name="category" type="text" class="formrightcolumn"  value="<?php echo $row_rs_faqcategory['category']; ?>" />
              <input name="save" type="submit" class="submitbutton" id="save" value="save" />
    </fieldset>
              <input type="hidden" name="MM_update" value="form1" />
       <?php } while ($row_rs_faqcategory = mysql_fetch_assoc($rs_faqcategory)); ?>
    </form>
    ************** The Form Ends *****************
    Cheers
    Dave

    What does debugging tell you? What's the value of each of the variables? Did you try using regular echo statements to monitor what's going on? That's what I always do whenever I am stuck in my PHP coding.

  • Line separator to get multiple records in one variable

    Hi Experts,
    I have a requirement where i need to get data in the below form , in exactly one variable.
    Invoice No.       Inv. Date      Voucher   Gross Amount    TDS Amount     Discount    Paid Amount  
    986013092,17   04/08/2010    00091217   32415.00            .00                 .00          32415.00
    Bharti Infot      27/07/2010     00091230   19600.00            .00                 .00          19600.00
    9860442689    04/08/2010       001247     47374.00            .00                  .00         47374.00
    2031565000,2031565000Total Amount     99389.00             .00                  .00         99389.00
    As of now, I have written the following,
    loop at lt_merge into ls_merge.
      lv_skfbt  = ls_MERGE-SKFBT.
      lv_budat  = Ls_MERGE-budat.
      lv_wskto  = Ls_MERGE-wskto.
      lv_wrbtr  = Ls_MERGE-wrbtr.
      lv_WT_QBSHB = ls_merge-WT_QBSHB.
    concatenate invoice_id
                ls_merge-BELNR
                lv_BUDAT
                ls_merge-XBLNR
                lv_skfbt
                lv_wt_qbshb
                lv_WSKTO
                lv_wrbtr
    into invoice_id separated by space.
    endloop.
    which gives me one row of the table where, invoice_id stores my entire one record as a string. My question is how do I proceed with separating the lines if I have multiple records?
    Thanks in advance..
    Regards,
    Trishna

    HI
    choose some character that will be not use in your data for example '|' vertical separator. You will get string:
    invoice_id  = line1 | line2 | line3 |.....
    loop at lt_merge into ls_merge.
    lv_skfbt = ls_MERGE-SKFBT.
    lv_budat = Ls_MERGE-budat.
    lv_wskto = Ls_MERGE-wskto.
    lv_wrbtr = Ls_MERGE-wrbtr.
    lv_WT_QBSHB = ls_merge-WT_QBSHB.
    concatenate invoice_id
    ls_merge-BELNR
    lv_BUDAT
    ls_merge-XBLNR
    lv_skfbt
    lv_wt_qbshb
    lv_WSKTO
    lv_wrbtr
    into invoice_id separated by space.
    new code
    concatenate  invoice_id '|' into invoice_id
    endloop.

  • Multi-mapping ... multiple records works, one record doesn't

    I'm using JDBC to select rows from an external Oracle database, XI receives the message, splits it into multiple messages (one for each record returned) and, using RFC/BAPI, takes each record and writes it to an SAP table on an SAP system.  I'm using the RB_SPLIT option in my Interface Determination and in my Interface Mapping I'm using Source occurrences = 1, Target occurrences = 0..unbounded. 
    This works GREAT ... as long as there is more than one record returned from the select statement in the JDBC setup.  If the select statement only returns one record, nothing gets transferred.  If it's any amount of records more than 1, it works perfectly.
    Why won't it process one record?  What can I do to get it to process one record, without messing up the great job it does for more than one record?
    Thanks!

    Hi Michael -
    I have a similar setup (at least on the sender side) and whether I have multiple records returned or just one, I'm getting my expected result.  FYI, I'm using a file receiver.
    I would first take a closer look at your mapping.  Get the one record XML that is sent to the Integration Server and test your message mapping in the IR.  Remember to put it in between the tags below:
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
       </ns0:Message1>
    </ns0:Messages>
    Regards,
    Jin

  • How can i create my BC featured product list in to a slide show for multiple products in one row. i have products aligned in a row i just would like to make it a slide show of the multiple (20) products.

    i have products aligned in a row already using custom css.i just would like to make it a slide show of the multiple (20) products in the one row.
    i am using the featured product module from the development section of business catalyst. i would love to display as many new products as possible in one row of products. so i can just click a arrow left button and scroll through the products.
    holy-shippers.businesscatalyst.com is the site i am mentioning.

    Hello,
    Aside from any custom implementations that may be suggested by any other members, you could also consider using some hero-type slider like those found on our new responsive templates, and have each web-app item contain a product.
    Kind Regards,
    Alex Pavelescu

  • How to store multiple records for one master reocrd using sequnce

    dear,
    my question is in one form i have master block f and detail block.
    my question is i created one sequence and assign to master table. but i dont know how to assign that sequence to multiple record in detail table for that particular master record. i got lots of answer previously but i m not getting exactly.pls tell me full procedure otherwise gv me one demo application
    NOTe: the sequnce is created after master record commiting to database.
    PLS pls help me
    Thanks
    damby

    i did not get answer pls help me.

  • Self join to get related records in one row

    I have a table that has individual records for each family member.
    tPerson.LastName, tPerson.FirstName, tPerson.RelationshipCode, tPerson.FamilyUnitCode, tPerson.JobCode
    Smith, John,HD, 1234, AD
    Smith, Jill, SP, 1234, TC
    Olson, Fred, HD, 2345, AV
    Olson, Wilma, SP, 2345, MD
    Adams, Nate, HD, 3456, DP
    Adams, Heidi, SP, 3456, DP
    Franks, John, HD, 4567, AV
    Williams, Pauline, HD, 5678, TC
    I need to get each family unit in one row, preferably without a group on, for a report because I need to compare the jobcodes of HD and SP to decide how to build an expression for a listing. I need to also get singles with no spouse info.
    FamilyCode, Lastname, HDFirstName, SPFirstName, HDJobCode, SPJobCode
    1234, Smith, John, Jill, AD, TC
    2345, Olson, Fred, Wilma, AV, MD
    3456, Adams, Nate, Heidi, DP, DP
    4567, Franks, John, NULL, AV, NULL
    5678, Williams, Pauline, NULL, TC, NULL
    Does the type on constraint affect the effect of an inner join? I have trouble getting the left side returning rows where there is no SP records for that familyCode.
    Any help? John

    >> I have a table that has individual records [sic] for each family member. <<
    Rows are not records. And you posted no DDL.
    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying
    temporal data. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    The sample data looks like it has a tibble on it. This is the classic design error of putting meta data, like a “t-” on tables and data element names. The next classic error you made
    is a table name that is singular and vague; do you really have only one “Person” in a table? According to ISO-11179 rules, that is what you said.
    >> I need to get each family unit in one row, ..<<
    Not in RDBMS. Please look up the term “1NF” or “First Normal Form” which forbids structure data in columns.
    But it just gets worse. Being in a family is a relationship, so it has its own table. The individuals are entities, so they have a table. Having a job is another relationship, so it is
    in a third table. In your world, all these things are crammed into a single table! This might be how an OO programmer would attempt to do RDBMS that first time, but it is not good. Here is skeleton to get your started: 
    CREATE TABLE Personnel
    (emp_id CHAR(9) NOT NULL PRIMARY KEY,
    last_name VARCHAR(20) NOT NULL,
    first_name VARCHAR(20) NOT NULL);
    CREATE TABLE Family_Units
    (family_unit CHAR(4) NOT NULL,
    relationship_code CHAR(5) NOT NULL
    CHECK (relationship_code IN ('spouse', ????)),
    PRIMARY KEY (family_unit, relationship_code),
    emp_id_1 CHAR(9) NOT NULL
    REFERENCES Personnel
    ON DELETE CASCADE,
    emp_id_2 CHAR(9) NOT NULL
    REFERENCES Personnel
    ON DELETE CASCADE,
    CHECK (emp_id_1 <> emp_id_2)
    CREATE TABLE Employment
    (emp_id_1 CHAR(9) NOT NULL
    REFERENCES Personnel
    ON DELETE CASCADE PRIMARY KEY,
    job_code CHAR(2) NOT NULL); -- do you know about DOT codes?
    See how we use DRI actions? Etc. 
    >> I need to compare the job_codes of HD and SP to decide how to build an expression [sic] for a listing. I need to also get singles with no spouse info. <<
    Expression return scalar values in SQL. You meant query. Where is the SQL you attempted? Is “spouse” the only relationship? 
    You have not posted enough information for anyone to really help you. What little we can extract from this says that you have no idea how about RDBMS. Want to do some reading, follow
    Netiquette and try again? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Merging multiple records onto one page

    I have two questions for successfully setting up a mail merge:
    1.  I have a .csv file that contains multiple records.  All but one column contains one line of text.  I have one column in the record that contains several paragraphs of text.
    Problem:  The merge sees the paragraph returns (or line breaks) as an indicator to go to the next record.  What's the work-around for this?
    2.  I need the records to flow one after another.
    Problem:  It's merging one record per page.
    Background that may help (maybe merge is not the feature I should be using):
    I'm designing a newspaper that contains about 150 book reviews.  The reviews stem from a database that I'm exporting as a csv.  Rather than converting/formatting the reviews from the database by hand (like I have been doing), I thought InDesign must have some automated way of handling this.
    This is an example of what one record looks like:
    Italian For Beginners
    By Kristen Hammel
    Random House, $12.95, 53 pages
    Don’t be fooled by the //Italian for Beginners// cover photo of an Audrey Hepburn look-alike on the back on an Italian motorcycle with her arms around a handsome man. This novel is stronger and meatier than another  “American falls in love in Italy” love story.  Yes, the protagonist Cat Connelly escapes to Italy to find herself after tiring of being the center of everyone’s dismay as an unmarried 34-year-old overly-responsible sister, daughter, and granddaughter.
    And yes, there is romance, but it comes with a twist.  The best part of the novel is watching Cat shed her carefully constructed identity and past.  Harmel’s character discovers an authentic Rome from a family, insider’s perspective. The Italizan zest for life and her own connection to Italy allows her to throw off her accountant-style persona and take risks.  As Cat examines her deep-seated fears and biases,  she also discovers those things that give her true peace, joy and satisfaction.
    Will Cat fall in love with a handsome Italian? Or will she fall in love with her own long-suppressed Italian heritage and natural gifts? Read the novel to find out, and you’ll also find a bonus at the end of the novel: five authentic  recipes inspired by Italian for Beginners.  Mangi, mangi, buon appetito!
    Reviewed by John Smith
    Can anyone help?

    First the easy part. To get multiple records per page, create only one placeholder in the upper left position. ID duplicates EVERYTHING on the page as many times as it can using your spacing selections. If you have one element at the top of the page and another at the bottom, for example, ID will not be able to put additional records on that page because there is no space.
    Text frames should be no larger than necessary to hold the data. They won't grow or shrink to fit during the merge, so you'll have gaps if the length of the text varies from record to record.
    Now, for how to fix the line-break problem. In the data file substitute a character, or group of characters you won't be using anywhre else for each return. After the merge use Find/Change to replace the substituted cahracters with real breaks.
    Peter

  • Update multiple records on one page

    I have a page that displays records based on a varible that
    is selected on
    the previous page.
    So on this page i have displaying 3 columns
    Store # Allowance Total
    They have asked now instead of clicking on each indivual
    record to mark it
    as completed, they would like to just place a check next to
    each one and let
    it update those records for that store....
    Ex.
    Store 20 has a total of 7 records and has an allowance of
    $6000.00 then
    they would place 1 check mark next to that store and hit
    submit and it would
    update all 7 records with a status of completed.
    I have read thru some not all but some of the example links i
    found for
    updating multiple records. But they seem more complex than
    what im trying to
    do. Since this page is populated dynamically how can i code
    it so it
    understands when there is new stores listed and records.
    Is there any links or tutorial that anyone would recommend
    that will explain
    the process for creating this functionality?

    My bad....
    ASP and Access is what im using DWMX
    "bregent" <[email protected]> wrote in
    message
    news:ei5srh$6uv$[email protected]..
    > What scripting model are you using? You may be able to
    find a datagrid for
    > your model which will simplify this for you.

  • Multiple rows to multiple columns on one row using SQL

    Hi
    I am attempting to select back multiple values for a specific key on one row. See the example below. I have been able to use the sys_connect_by_path to combine the fields into one field but I am unable to assign them to fields of their own. See the example below
    TABLE DETAILS:
    Policy id plan name
    111 A Plan
    111 B Plan
    111 Z Plan
    112 A Plan
    112 Z Plan
    My desired result is to be able to show the output as follows
    Policy ID Plan_1 Plan_2 Plan_3
    111 A Plan B Plan Z PLan
    112 A Plan Z PLan
    Can you help???

    Thanks for all the replies. Perhaps I could give a little more detail incldung a sample table and insert statements. The repsonses work fine but the problem I was having was that I did not want to have to hardcode in the plan_name to a decode statement. The list of plans is not exhaustive. There could be numerous different plans in the table. I have amended the details below slightly to try and give a little more information as I was probably not too clear at the start. Would you know if there is a way to do this without hardcoding the plan values in?
    Thanks in advance!
    CREATE TABLE TEST_SAMPLE (
    POLICY_NUMBER VARCHAR2(10),
    plan_name varchar2(20) );
    INSERT INTO TEST_SAMPLE VALUES ('111', 'A Plan');
    INSERT INTO TEST_SAMPLE VALUES ('111', 'B Plan');
    INSERT INTO TEST_SAMPLE VALUES ('111', 'C Plan');
    INSERT INTO TEST_SAMPLE VALUES ('112', 'J Plan');
    INSERT INTO TEST_SAMPLE VALUES ('112', 'Z Plan');
    My desired result is to be able to show the output as follows
    Policy ID Plan_1 Plan_2 Plan_3
    111 A Plan B Plan C PLan
    112 J Plan Z PLan

Maybe you are looking for

  • Multiple crashes in nspect.exe during system update

    While running Lenovo System Update on a stock ThinkPad T61 with 3 MB memory running the initial install of Windows XP, there are multiple reports of a crash in nspect.exe . A typical message from the Application Log is: Event Type:     Error Event So

  • How to download photos and video from cloud to computer?

    How do I download my photos and videos from Verizon Cloud to my computer, more specifically, my external hard drive? I'm out of cloud storage.

  • Single server solution for RDS / TS / RDP using Windows Server 2012 R2

    Planning on setting up a small single server and  need this functionality: * 3 local users runnnig Windows 7 Home Premium needs to access files on the server * The same 3 users should also be able to connect from home (PC, Mac, iPhone) and run an app

  • Garbage characters on PDF output

    My PDF documents converted from Word sometimes have a short bit of garbage characters just about the TOC.  Not everyone sees the characters on the document. It only is visible to a few individuals. See the attached. Is there a setting that needs atte

  • Newsletter is too wide for Mail window

    I receive a monthly email newsletter. It is hard to read because the text is wider than the window, necessitating constant left and right scrolling. I had the same problem before I changed monitors. Some other Mac users are writing in to the editor w