Create a view to shows data from multiple rows in a single column

Hi all - this is probably posted in the wrong forum but I couldn't find which was the correct one.
I am almost a complete novice at sql but I have a need to create a view which can be developed at 10g (which runs efficiently as the volumes are likely to be high) which will do the following.
Original table with columns Parent_code, Child_code
Parent_Code Child_Code
1000 2000
1000 3000
1000 4000
2000 3000
2000 5000
(note Parents can have multiple children and a child can have multiple parents!)
What I need to end up with in my view is the following
Child_Code Parent_List
2000 '1000 (3)'
3000 '1000 (3), 2000 (2)'
4000 '1000 (3)'
5000 '2000 (2)'
Note the number in parantheses is the number of children that the parent has - ie in the original table parent 1000 has 3 rows (one for each child)
This view is then to be used as a look up (on child code) for a business objects report.
Is there anyone who could PLEASE, PLEASE help me fairly quickly on this as I have very little time to find a solution?

Hi,
You can test these ones :
select child_code
     , ltrim(sys_connect_by_path(parent_info,', '), ', ') as parent_list
from (
  select child_code
       , to_char(parent_code) ||
         ' (' ||
         count(*) over(partition by parent_code) ||
         ')' as parent_info
       , row_number() over(partition by child_code order by parent_code) rn
  from your_table
where connect_by_isleaf = 1
connect by prior rn = rn-1
       and prior child_code = child_code
start with rn = 1
select child_code,
       rtrim(
         extract(
           xmlagg(xmlelement("e",parent_info||', ') order by parent_info)
         , '//text()'
       ) as parent_list
from (
  select child_code,
         to_char(parent_code) ||
         ' (' ||
         count(*) over(partition by parent_code) ||
         ')' as parent_info
  from your_table
group by child_code
;What you need is called "string aggregation".
See here for various techniques, including the two above : http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

Similar Messages

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • Selecting data from Multiple Partitions in a single select stmt.

    Hi all,
    My Database is very large & my tables are partitioned.
    My question is:
    1) If my data is spread across multiple partitions, is there any way to select data from multiple partitions in a single query?
    If we dont mention partition name also it works fine, but perofmance wise it will be very slow. (Using EXPLAIN PLAN)
    (Note:I dont want to make use of Union concept, i want to do it in a single select statement)
    For ex:
    qry1.sql:
    select empno from emp_trans partition (P012000)
    This above query(qry1.sql) will work fine.
    qry2.sql:
    select empno from emp_trans partition (P012000,P022000)
    The above query(qry2.sql) will return will return the following error:
    ORA-00933: SQL command not properly ended
    If anybody has any solution for this, pls mail me immediately.
    Thanks in advance
    bye
    null

    All my queries are dynamically generated. All my tables are also indexed partition wise based on date field. My question is, if i want to mention multiple partition names at the time of generating my query(select), then with parformance will be good. I have refered some books, inthat what they say is to use UNION concept, i dont want to use that, instead i want in a single select statement.
    Thaks for ur reply
    Bye
    null

  • Move data from multiple Tables to a Single Table & Convert the list to ALV.

    Hi,
    My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
    Also tell me how to convert this list into ALV.
    Below is the program code.
    *& Report  Y_REORDER_REPORT
    REPORT  Y_REORDER_REPORT.
    tables : marc,makt, mard.
    DATA: Begin of i_final occurs 0,
            matnr type marc-matnr,
            maktx type makt-maktx,
            DISPO type marc-DISPO,
            MINBE type marc-MINBE,
            LABST type mard-LABST,
          end of i_final.
    DATA: Begin of i_marc occurs 0,
           matnr type marc-matnr,
           DISPO type marc-DISPO,
           MINBE type marc-MINBE,
          end of i_marc.
    DATA: Begin of i_makt occurs 0,
           matnr type makt-matnr,
           maktx type makt-maktx,
          end of i_makt.
    DATA: Begin of i_mard occurs 0,
           matnr type mard-matnr,
           LABST type mard-LABST,
           LGORT TYPE MARD-LGORT,
          end of i_mard.
    SELECT  matnr
            dispo
            minbe from marc
            into corresponding fields of table i_marc
            where dispo EQ 'STR'.
    SORT I_MARC by MATNR.
    WRITE: /10  'Material',
            75  'MRP',
            80  'Reorder Qty.'.
    LOOP at i_marc.
    Write: /10  i_marc-matnr,
            75  i_marc-dispo,
            80  i_marc-minbe.
    ENDLOOP.
    write: /.
    SELECT  matnr
            MAKTX from makt
            into corresponding fields of table i_makt
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_makt.
    Write: /10 i_makt-matnr,
            30 i_makt-maktx.
    ENDLOOP.
    SELECT  matnr
            LGORT
            LABST from mard
            into corresponding fields of table i_mard
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_mard.
    Write: /10 i_mard-matnr,
            30 I_MARD-LGORT,
            40 i_mard-labst.
    ENDLOOP.
    move  i_mard-matnr to i_final-matnr.
    move  i_marc-dispo to i_final-dispo.
    move  i_marc-minbe to i_final-minbe.
    move  i_makt-maktx to i_final-maktx.
    move  i_mard-labst to i_final-labst.
    WRITE: /10  'Material',
            30  'Material Desc.',
            75  'MRP',
            80  'Reorder Qty.',
            105 'Current Stock'.
    LOOP at i_final.
    Write: /10  i_final-matnr,
            30  i_final-maktx,
            75  i_final-dispo,
            80  i_final-minbe,
            105 i_final-labst.
    ENDLOOP.
    *LOOP at i_mard.
    *Write: /10  i_mard-matnr,
           30  i_makt-maktx,
           75  i_marc-dispo,
           80  i_marc-minbe,
           105 i_mard-labst.
    *ENDLOOP.
    Regards,
    Vishal

    Change like this,
    SELECT matnr
    lgort
    labst FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_mard
    FOR ALL ENTRIES IN i_marc
    WHERE matnr = i_marc-matnr.
    LOOP AT i_mard.
       WRITE: /10 i_mard-matnr,
       30 i_mard-lgort,
       40 i_mard-labst.
    ENDLOOP.
    LOOP AT i_marc.
       READ TABLE i_mard WITH KEY matnr =  i_marc-matnr.
       READ TABLE i_makt WITH KEY matnr =  i_marc-matnr.
       MOVE i_mard-matnr TO i_final-matnr.
       MOVE i_marc-dispo TO i_final-dispo.
       MOVE i_marc-minbe TO i_final-minbe.
       MOVE i_makt-maktx TO i_final-maktx.
       MOVE i_mard-labst TO i_final-labst.
       APPEND i_final.
    ENDLOOP.
    WRITE: /10 'Material',
    30 'Material Desc.',
    75 'MRP',
    80 'Reorder Qty.',
    105 'Current Stock'.

  • How do you receive data from multiple people on a single port?

    I am trying to make a server where it receives the data from multiple users and then send it back to them all- multicasting audio to be exact. I tried setting it up but when i open the RTP session i get "can't open local data port" if i have more than one used connected to me. Does anyone have a solution? I didnt find much on the samples page and the multicast example from http://java.sun.com/products/java-media/jmf/2.1.1/apidocs/javax/media/rtp/RTPManager.html
    didnt help either- i used the same ipaddress for the initialize and addtarget but i get "Local Data AddressDoes not belong to any of this hosts local interfaces". I am really in a pickle... If anyone can help me out that would be great!
    EX: If A,B,C want to multicast they will all send to Server S using port 3000. Server S will create listeners for each of them using port 3000 and when received data it will send back to all of them at 4000. This is what i am trying to do... should i make multiple threads? would that help? thanks and please help!

    To send to everyone, you can send to a multicast address (choose one from 224.0.0.0 to 239.255.255.255), on a given port (2000). I don't have any code example here but it should very similar to unicast. As you said, you just have to register the Session and add a target with this same address.
    I don't have any example myself, but you should find code example of both server and client around. It is a very common usage of jmf rtp.
    I don't know how to mix several audio streams together (never had to do this), so I'm afraid I can't answer your other questions, sorry... The only way to know if it will slow down the transmission is to try. :)

  • How to submit data from multiple Input Ports in single SUBMIT button  click

    Hi,
    I am in SPS8.
    What exactly steps I need to perform to submit data from multiple Input Ports.
    I couldn't able to submit One input Form and one Input Table to BAPI data service in single SUBMIT button click.
    I debugged the VC application in SPS8.
    While debugging, I found that when I click the SUBMIT button in the Input Form, Only data in that Input
    form are being passed to the BAPI, But not the Table Form data.
    If I click on the SUBMIT button in another Input Table, Only data from that table is being passed to the BAPI, but not the Input form data.
    Essentially I need to submit both of them in one SUBMIT button.
    Thanks,
    Ramakrishna

    Ramakrishna,
    From the word document that you sent to me the steps you are missing to map the appropriate information into the BAPI is first you are not mapping all data rows into the table input port. To do this double click on the input table view and change your selection mode from single to multiple. Then when you click on your link between the BAPI and your input table you will see a new option appears under data mapping "Mapping Scope" select All Data Rows.
    That's the first part of the problem to get the BAPI to recognize both the inputs coming from the form and the table eliminate the submit button from the form. Drag and drop a link from the output port of the table view to the Input port of the BAPI. Double click on the link between the BAPI and the table view and open the expressions editor for the two fields:
    1/ Automatic Source
    2/ SKIP_ITEMS_WITH_ERROR
    On the hierarchical folder structure on the right expand expand the Data Fields node to find the fields from the form and map them accordingly.
    Now when you hit the submit button on your table it should pass the BAPI all the parameters from both the form and the table.
    Hope this helps,
    Cheers,
    Scott

  • How to create a view consisting of data from tables in2 different databases

    Using Oracle 10.2g
    I have 2 databases Gus and haggis on Comqdhb schema.
    glink indicates a databse link between Haggis and Gus
    In Gus there are tables student,subject,grade,school containing columns like upn...
    STUDENT
    upn
    academicYear
    SUBJECT
    subject
    GRADE
    examlevel
    grade
    SCHOOL
    sn
    In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
    STUDENT
    upn
    GRADE
    grade
    upn
    academicyear
    level
    Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    so I need to create a view which gets the data from both the tables in both the databases.
    create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
    But i am not getting how to select a column from 2 tables in different databases
    I mean if i said
    select upn from comqdhb.student@glink,comqdhb.student;
    select upn from comqdhb.student@glink,comqdhb.student
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    help me out,Thank you.

    Thank you for the reply will follow up the code format
    Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    I understand that there wont be duplication when we use conditions
    If i query
    select count(upn)
    from   comqdhb.student@glink I get 9000
    but after the union
    create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
    as
    select distinct s.upn as upn
    ,                  g.subject as subject
    ,                  g."LEVEL" as examlevel
    ,                  g.grade as grades
    ,                  '9364097'
    ,                  to_number(g.academicyear) as academicyear
    from             comqdhb.student s
    ,                   comqdhb.grade g
    where           s.upn=g.upn
    union
    select            s.upn
    ,                   sb.subject
    ,                   g.elevel
    ,                   g.grade
    ,                   s.acyr
    ,                   sc.sn
    from              comqdhb.subject@glink sb
    ,                   comqdhb.student@glink s
    ,                    comqdhb.gradevalues@glink g
    ,                    comqdhb.school@glink sc,
    ,                    comqdhb.studentingroup@glink sg
    ,                    comqdhb.teachinggroup@glink tg
    where            sb.sid=tg.sid
    and                tg.gid=sg.gid
    and                sg.upn=s.upn
    and                g."LEVEL"=tg.elevel
    and                s.school=sc.id
    and                sc.id=tg.id; returns
    count(upn) from exam gradeIt gets stuck actually sometimes it returns
    932002 some results.
    2:
    Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
    Information:
    =======
    All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
    They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
    For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
    In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
    Grade Numerical score
    A* 8
    A 7
    B 6
    C 5
    D 4
    E 3
    F 2
    G 1
    U 0
    X 0
    Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
    In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
    add them all up and div by the total no of grades to get the avg.
    desc comqdhb.STUDENT@glink;
    STUDENT
    =======
    UPN
    FNAME
    CNAME
    DOB
    GENDER
    PREVIOUSSCHOOL
    XGCSE
    SCHOOL
    ACYR
    STUDENTINGROUP
    =============
    UPN
    GID
    STARTDATE
    ENDDATE
    GRADE
    GRADEVALUES
    ===========
    GRADE
    LEVEL
    VALUE
    I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
    select *
    from comqdhb.student@glink
    where xgcse<6.5; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
    select *
    from comqdhb.student@glink
    where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
    my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1011;
    Result:
    GRADE
    =====
    D
    F
    B
    E
    C
    E
    E
    B
    8 rows selected. Mapping each grade to the corresponding value and calculating we get
    32/8=4 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386;
    Result:
    GRADE
    ======
    A*
    A*
    A*
    A*
    B
    A*
    A*
    A
    B
    B
    B
    11 rows selected. grade to the corresponding value and calculating we get
    79/11=7.12 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
    But another problem
    when i say
    select   g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ===========
      100 B
      100 B
       80 C
       60 D
       40 E
       40 E
       40 E
       20 F
        6 B
        6 B
        5 C
    VALUE GRADE
    =============
        4 D
        3 E
        3 E
        3 E
        2 F
    16 rows selected.
    select   distinct g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ============
         2 F
       100 B
         6 B
         3 E
        60 D
         5 C
         4 D
        80 C
        40 E
        20 F
    10 rows selected. I am getting only 8 for the query
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
    select distinct *
    from   comqdhb.gradevalues@glink;
    GRADEVALUES
    ===========
    LEVEL      GRADE           VALUE
    ================================
    a          A                 120
    a          B                 100
    a          C                  80
    a          D                  60
    a          E                  40
    a          F                  20
    a          U                   0
    a          X                   0
    g          A                   7
    g          A*                  8
    g          B                   6
    LEVEL      GRADE           VALUE
    ================================
    g          C                   5
    g          D                   4
    g          E                   3
    g          F                   2
    g          G                   1
    g          U                   0
    g          X                   0
    18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
    select  sum(g.value)/count(g.grade) as avggrade
    from    comqdhb.gradevalues@glink g
    ,         comqdhb.studentingroup@glink sg
    where  g.grade=sg.grade
    and     sg.upn=1386;
    avggrade
    ========
    37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
    kindly help.
    Edited by: Trooper on Dec 15, 2008 4:49 AM

  • Extracting specific data from multiple text files to single CSV

    Hello,
    Unfortunately my background is not scripting so I am struggling to piece together a powershell script to achieve the below. Hoping an experienced powershell scripter can provide the answer. Thanks in advance.
    I have a folder containing approx. 2000 label type files that I need to extract certain information from to index a product catalog. Steps to be performed within the script as I see are:
    1. Search folder for *.job file types
    2. Search the files for certain criteria and where matched return into single CSV file
    3. End result should be a single CSV with column headings:
    a) DESCRIPTION
    b) MODEL
    c) BARCODE                                                                                                                   

    Try:
    # Script to extract data from .job files and report it in CSV
    # Sam Boutros - 8/24/2014
    # http://superwidgets.wordpress.com/category/powershell/
    $CSV = ".\myfile.csv" # Change this filename\path as needed
    $Folders = "d:\sandbox" # You can add multiple search folders as "c:\folder1","\\server\share\folder2"
    # End Data entry section
    if (-not (Test-Path -Path $CSV)) {
    Write-Output """Description"",""Model"",""Barcode""" | Out-File -FilePath $CSV -Encoding ascii
    $Files = Get-ChildItem -Path $Folders -Include *.job -Force -Recurse
    foreach ($File in $Files) {
    $FileContent = Get-Content -Path $File
    $Keyword = "viewkind4"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i] -match $Keyword) {
    $Description = $FileContent[$i].Split("\")[$FileContent[$i].Split("\").Count-1]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    $Keyword = "Code:"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i]-match $Keyword) {
    $Parts = $FileContent[$i].Split(" ")
    for ($j=0; $j -lt $Parts.Count; $j++) {
    if ($Parts[$j] -match $Keyword) {
    $Model = $Parts[$j+1].Trim()
    $Model = $Model.Split("\")[$Model.Split("\").Count-1]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    $Keyword = "9313"
    if ($FileContent -match $Keyword) {
    for ($i=0; $i -lt $FileContent.Count; $i++) {
    if ($FileContent[$i] -match "9313") {
    $Index = $FileContent[$i].IndexOf("9313")
    $Barcode = $null
    for ($j=0; $j -lt 12; $j++) {
    $Barcode += $FileContent[$i][($Index+$j)]
    } else {
    Write-Host "Keyword $Keyword not found in file $File" -ForegroundColor Yellow
    Write-Output "File: '$File', Description: '$Description', Model: '$Model', Barcode: '$Barcode'"
    Write-Output """$Description"",""$Model"",""$Barcode""" | Out-File -FilePath $CSV -Append -Encoding ascii
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable)

  • Collecting data from multiple rows into one column

    I'd like to run a query and put a collection of items into one output column instead of multiple rows. See the example below:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    "CORE     10.2.0.5.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
         CREATE TABLE "SKIP"."INGREDIENTS"
       (     "INGRED_ID" NUMBER,
         "INGRED_NAME" VARCHAR2(20 BYTE),
         "STORES" VARCHAR2(20 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGREDIENTS
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (1,'SEA SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (2,'TABLE SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (3,'FLOUR','Piggly Wiggly');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (4,'YEAST',null);
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (5,'BEER','ABC Store');
      CREATE TABLE "SKIP"."PRETZELS"
       (     "PRETZEL_ID" NUMBER,
         "PRETZEL_NAME" VARCHAR2(20 BYTE),
         "PRETZEL_DESC" VARCHAR2(100 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.PRETZELS
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (1,'CLASSIC','Classic knot pretzel');
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (2,'THICK STICK','Straight pretzel, abt 1/2" in dia');
      CREATE TABLE "SKIP"."INGRED_XREF"
       (     "PRETZEL_ID" NUMBER,
         "INGRED_ID" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGRED_XREF
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,1);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,4);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,3);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,5);
    --  Constraints for Table INGRED_XREF
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("PRETZEL_ID" NOT NULL ENABLE);
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("INGRED_ID" NOT NULL ENABLE);
    {code}
    Desired output (note how the ingredients are all listed in one column, separated by commas):
    {code}
    PRETZEL_ID PRETZEL_NAME     PRETZEL_DESC                        INGREDIENTS
    1          CLASSIC          Classic knot pretzel                SEA SALT, TABLE SALT, YEAST
    2          THICK STICK      Straight pretzel, abt 1/2" in dia   TABLE_SALT, FLOUR, BEER

    See the FAQ : {message:id=9360005}
    Especially links concerning string aggregation.

  • How to read data from multiple files and append in columns in one file

    Hi Guys,
    I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
    Solved!
    Go to Solution.
    Attachments:
    Write to file.vi ‏13 KB
    A.txt.txt ‏1 KB
    B.txt.txt ‏1 KB

    You cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
    (I also don't think you need to set the file positions, it will be remembered from the last write operation.)
    Unless the files are gigantic, here's what I would do:
    (Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
    EDIT: It seems Dennis's solution is similar )
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Write to fileMOD.zip ‏6 KB
    MergeColumns.png ‏6 KB

  • How to genereate multiple IDOCs from multiple rows in a single flat file

    HI,
    I am working on a scenario where I need to genereate a IDOC per one row in a flat file.
    I created DT of following strcuture:
    DT_TYPE
    --DETAILS -
    0..Unbound
    F1------0..Unbound
    F2------0..Unbound
    F3------0..Unbound
    IDOC is
    ZIDOC
    IDOC----1..1
    -BEGIN-Required
    -SEGMENT1---1..1
    -SEGEMENT2-1..1
    -SEGMENT3-1..999
    To create multiple IDOCs if there are multiple rows in a flat file in MM i choosed occurances as 0..unbound in Signiture tab
    Source structure:
    Messages------1...1
    -Message1--1....1
    DT_TYPE------0..Unbound
    DETAILS -
    0..Unbound
    F1------0..Unbound
    F2------0..Unbound
    F3------0..Unbound
    Target Strcuture:
    Messages----1....1
    -Message--1....1
    ZIDOC----1....1
    IDOC------1..1
    BEGIN---Required
    SEGMENT1-----1..1
    SEGEMENT2---1..1
    SEGMENT3---1..999
    I am unable to generate two IDOCs if there are two rows:
    Am I missing some thing?
    Thanks
    Rajeev

    HI,
    I am working on a scenario where I need to genereate a IDOC per one row in a flat file.
    I created DT of following strcuture:
    DT_TYPE
    --DETAILS -
    0..Unbound
    F1------0..Unbound
    F2------0..Unbound
    F3------0..Unbound
    IDOC is
    ZIDOC
    IDOC----1..1
    -BEGIN-Required
    -SEGMENT1---1..1
    -SEGEMENT2-1..1
    -SEGMENT3-1..999
    To create multiple IDOCs if there are multiple rows in a flat file in MM i choosed occurances as 0..unbound in Signiture tab
    Source structure:
    Messages------1...1
    -Message1--1....1
    DT_TYPE------0..Unbound
    DETAILS -
    0..Unbound
    F1------0..Unbound
    F2------0..Unbound
    F3------0..Unbound
    Target Strcuture:
    Messages----1....1
    -Message--1....1
    ZIDOC----0....unbound
    IDOC------1..1
    BEGIN---Required
    SEGMENT1-----1..1
    SEGEMENT2---1..1
    SEGMENT3---1..999
    I am unable to generate two IDOCs if there are two rows:
    Am I missing some thing?
    It isnt possible with out BPM?
    Thanks
    Rajeev

  • 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

  • Updating data from multiple rows in a table view

    Hello,
    so far in my OAF programming, I have always selected one particular row from a table and saved from it. Now I have a requirement where in my table, fields from more than one row shall have to be updated.
    Can anyone please let me know how to accomplish this.
    Regards
    Hawker

    Hi Prince,
    currently I am selecting one row from the table and rendering a region at the top of the table and capturing the user entered data with the following code:
    ViewObjectVOImpl vo = getViewObjectVO1();
    Row CurrentRow = vo.getCurrentRow();
    //After this I perform the checks like user entered value is not null or check input as per business logic.
    if(CurrentRow.getAttribute("attributeName") ==null){
    //Add what message you want to display
    //Add other business logic.
    After making all the checks, i commit it.
    getOADBTransaction().commit();
    Now in my new page I am capturing the user input in the table itself like an excel sheet. Suppose there are ten rows in my advanced table on my page, and each row has one editable field. I have one save button at the bottom of the table.
    Now on clicking the save button I have to capture the user input, check whether there is any null value and if all the entered data is correct then only I should commit it.
    Can you please let me know how we can accomplish that.
    Regards
    Hawker

  • Insert data from two rows into a single row in a new table

    Hi
    i have a table like the following
    Deptno Dname      Salary
    10     Computer     2000
    10     Computer     4000
    10     Computer     3000
    10     Science     6000
    10     Science 1000
    10     Science     4000
    10     Science     10000
    I want to insert data into a new table like the following
    Deptno MaxSalCom     Minsalcom MinSalSci     MaxSaSci
    10     2000     4000      1000     10000
    Deptno--As in Table1
    MaxSalCom--Maximum salary for Dname " Computer"
    Minsalcom--Minimum salary for Dname " Computer"
    MaxSalSci--Maximum salary for Dname " Science"
    MinsalSci--Minimum salary for Dname " Science"
    Please help me how to go about it

    with data as
    (select 10 dno, 'Computer' dname, 2000 sal FROM dual
    union all
    select 10, 'Computer', 4000 FROM dual
    union all
    select 10, 'Computer', 3000 FROM dual
    UNION all
    select 10, 'Science', 6000 FROM dual
    union all
    select 10, 'Science', 1000 FROM dual
    union all
    select 10, 'Science', 4000 FROM dual
    union all
    select 10, 'Science', 10000 FROM dual
    select dno, min(decode(dname,'Computer',sal)) min_sal_comp , max(decode(dname,'Computer',sal)) max_sal_comp,
    min(decode(dname,'Science',sal))min_sal_sci , max(decode(dname,'Science',sal)) max_sal_sci
    from data
    group by dno;

  • How to display the multiple rows in a single column ?

    Hi,
    I have the Query like this :
    SELECT MS.SUBJECT, MS.MESSAGEDESC, MS.MSGDATE, MAT.ATTACHMENT
    FROM MESSAGES MS, MSESAGEATTACHEMTASSO MAA, (select pga.programid,
    act.accountname,
    row_number() over(partition by pga.programid order by act.accountname) rn
    from accounttypes act, programpursesasso pga
    where act.accounttypeid = pga.accounttypeid ) MSGATTACHMENTS
    WHERE MS.MESSAGEID = MAA.MESSAGEID
    AND MAA.MSGATTACHMENTID = MAT.MSGATTACHMENTID
    AND MS.MESSAGEID = 1;
    If i have multiple messageAttachments for single message ., i want to display them in a single row.,
    like :
    subject messagedesc msgdate attachment1 attachment2 .....attachmentn
    test test 10/10/2007 test test test
    can any one help me out ., how can i do this using simple sql query ?

    Hi,
    Thanks for the Reply .,
    I have the 2 table like :
    DESC MESSAGES;
    Name Type Nullable Default Comments
    MESSAGEID NUMBER(16)
    EMAILFROM VARCHAR2(50) Y
    EMAILTO VARCHAR2(50) Y
    SUBJECT VARCHAR2(500) Y
    MESSAGEDESC VARCHAR2(2000) Y
    MSGDATE DATE Y
    MSGSTATUS NUMBER(1) Y
    MSGDELETESTATUS NUMBER(1) Y
    SQL> DESC MESSAGES;
    Name Type Nullable Default Comments
    MESSAGEID NUMBER(16)
    EMAILFROM VARCHAR2(50) Y
    EMAILTO VARCHAR2(50) Y
    SUBJECT VARCHAR2(500) Y
    MESSAGEDESC VARCHAR2(2000) Y
    MSGDATE DATE Y
    MSGSTATUS NUMBER(1) Y
    MSGDELETESTATUS NUMBER(1) Y
    SQL> DESC MSGATTACHMENTS;
    Name Type Nullable Default Comments
    MSGATTACHMENTID NUMBER(16)
    ATTACHMENT CLOB
    ATTACHMENTDATE DATE Y
    SQL> DESC MSESAGEATTACHEMTASSO;
    Name Type Nullable Default Comments
    MSGATTCHID NUMBER(16)
    MESSAGEID NUMBER(16) Y
    MSGATTACHMENTID NUMBER(16) Y
    What I need Is :
    If One Msg is having multiple attachement , then i want to display all the attachment in a single row along with MsgSubject, MsgDate, MsgDesc like
    I want to dipaly the MsgSubject, MsgDesc, MsgDate, Attachment1
    MsgSubject MsgDate Msgdesc Attachment1 Attachment2 Attachment3 ...etc

Maybe you are looking for

  • How to download a file from Application Sever to Client Workstation?

    Hi All, I know how to move a file from client workstation to Application server. How to download that uploaded file from Application file (AL11)  directory to local desktop? Regards, Arun.M.D

  • Why can't I just load all my music onto my iPod

    I hesitantly got iTunes match and only because songs were not loading on my iPod because apple thought that I stole them. Some of those songs were loaded from CD's years ago and the CD's have long since been discarded or sold, some of those songs are

  • End date on data definition does not seem to work

    I made a mistake with a data definition, and have tried end dating it and starting again but when I try to create a new data definition I get an error that a data definition already exists with this Name or Code. How do I get around this ? My mistake

  • ICal Time Zone

    Whenever I make a new calendar event in iCal on my iPhone (3GS with iOS 4.1) it posts the event to iCal as being in Central Timezone. My phone is set to automatic time (I live in NJ and the time displayed on the phone is correct). I have to manually

  • Deployment Strategies

    I am working in a medium project that have in average 200 CMP entity beans. Actually, we have a mapping between each data base table with a CMP. Every time that we develop a new functionality the jar grows up and in fact, the deploying time grows up.