Create views of data from multiple lines in a single column shows

Hi all - it's probably posted in the wrong forum, but I couldn't find that was right.

I'm almost a perfect beginner in sql, but I have a need to create a view that can be expanded to 10g (which effectively runs the volumes are likely to be high) who will do the following.

Authentic table with columns Parent_code, Child_code
Parent_Code Child_Code
1000-2000
1000-3000
1000-4000
2000 3000
2000-5000

(note that Parents may have several children and a child can have multiple parents!)

What I have to finish with in my opinion 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 parentheses is the number of children whose parent's - IE in the original parent a 1000, 3 table lines (one for each child)

This point of view should be used as a quick glance upward (on the children's code) for a report of business objects.

Is there someone who could you PLEASE, PLEASE help me quickly on what I have very little time to find a solution?

Hello

You can test these:

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 'chain aggregation '.
See here for the various techniques, including the two above: http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

Tags: Database

Similar Questions

  • How to create views of data from different databases tables in2

    Using Oracle 10.2 g

    I have 2 databases Gus and the haggis on schema Comqdhb.

    Glink indicates a link of database between Haggis and Gus

    In Gus, there is school that contains columns with same name upn, grade, subject, student of tables...

    STUDENT
    UPN
    academicYear

    Object

    Object

    GRADE
    examlevel
    grade

    SCHOOL
    SN

    In HAGGIS raising tables, grade, teacher containing columns upn... desc below.

    STUDENT
    UPN

    GRADE
    grade
    UPN
    academicyear
    level



    Create views in your database HAGGIS who join their all the qualities of the review. You should have a point of view that will produce the following relationship:
    examGrade (upn, subject, examlevel, sn, rank, academicYear)

    So I need to create a view that gets the data from the tables in the databases.

    create view as examGrade (upn, subject, examlevel, sn, rank, academicYear) like some s.upn


    But I don't get the selection of a column of 2 tables in different databases

    I mean if I said

    Select the UPN in comqdhb.student@glink,comqdhb.student;
    Select the upn name in comqdhb.student@glink,comqdhb.student
    *
    ERROR on line 1:
    ORA-00918: column ambiguously defined

    Help me, thank you.

    Hello

    Rider wrote:
    The issue is that I can't understand that I should create the view by the union of the haggis and the two gus data or only haggis.
    the reason I believe I need to combine the two is mentioned * "" create views in your database schema HAGGIS who join their all the qualities of the review. ". *
    By the mention of creating views and who join their all the qualities of the review, it probably means to obtain the data of the GUS and HAGGIS.

    This is my interpretation of the assignment, too.
    If you ask just the tables on Gus, you will get the ranks of three of the four schools: it's not all examination classes.
    If you ask just the tables on Haggis, you will get the ranks of any of the four schools: it's not all examination classes.

    2nd prob is that if have decided to create a view that gets the data from these two gus and therer haggis would be a lot of duplication involved due to the cross product

    Why would there be "repetition involved due to the cross-product"?
    If the quuery of Gus produces 100 lines, the request of product Haggis 30 rows, then the UNION of the two will have 100 + 30 = 130 lines (assuming, as you say, each student is at school only one).

    the query I wrote is

    Create view examGrade (upn, subject, examlevel, sn, rank, academicYear)
    as
    Select distinct s.upn as upn, g.subject as topic,
    g."LEVEL" as examlevel, g.grade as rank, to_number (g.academicyear) as academicyear
    of s comqdhb.student, comqdhb.grade g
    s.UPN, sb.subject, g.elevel, g.grade, s.acyr select Union
    of comqdhb.subject@glink sb,comqdhb.student@glink s,comqdhb.gradevalues@glink g;

    You should not write, not to mention not formatted zip code. I have a little time I can devote to answering questions in the forum. Do you want me
    b spend this time formatting your code, so I can understand the question, and no time to answer, or
    b spend only a little time reading understanding your code and spend most of my time to help you?
    I would prefer (b), but the choice is yours.
    See the statement that I posted in my last post for an example of the formatted code. You see how it appears in a box with a police fixed-width, and multiple spaces are printed? This is because I typed {code} (all small letters), before and after the section I wanted formatted.

    At least put each table in the FROM clause on a separate line, so it is easy to know if you have enough join conditions.
    If you have N tables in the FROM clause, you almost always have at least N-1 join conditions that specify how the tables are linked together. For example, if talk you about two tables, quality and student, you expect to see a join condition that tells you when you have data in a table, how to find related data in the other table, such as

    g_gus.upn = s_gus.upn
    

    No no no join conditions will cause "repetition involved due to the cross product.

    I downloaded my info here
    http://www.upload4free.com/download.php?file=44201983-School_ExamGrades.PDF


    http://www.upload4free.com/download.php?file=184648736-ExamGrades_Case_Study_2008FINAL.PDF

    Sorry, if there is data as long as you can't post here, there is much too much for me to read.
    Make a sample set, containing a few (maybe five) students and a few shades of each student. It is fine to copy a few lines of your actual data.

    That's all the time I have for today. I can't wait to get the data and formatted requests.

  • Can we use Source accounting entity group to load the data from multiple entities with a single rule to load?


    Page 79 of erpi_admin_11123200.pdf says that "reporting entity groups are used to extract data from several reporting entities in a single data rule execution.  I use standard EBS adapter to load data in HFM application, I created a group of entity made up of several accounting entities, but I can't find a place in FDMEE where you get to select/use this group... When you define an import format you type the name and select Source (e, g. EBS) system you can select Map Source (for example EBS11 I adapter) or the accounting entity (it is what I select to define data load maps), but not both.  Note that there is no place to select the Group of accounting entity...  Location check menu group entity drop-down but it doe not my group of accounting entity which I believe is anyway something different... and creating a location and pointing to a format compatible with the selected Source adapter is no not good either... I'm confused, so is it possible to load data from several reporting entities in one rule to load or am I misreading the documentation?  Thank you in advance.

    Do not leave the field blank in the Import Format. If leave you empty to the place, when you set the rule to load data (for the location with EBS as a Source system), you will be able to select a single accounting entity or a group of accounting entity.

    You can see here

    Please mark this as useful or answer question so that others can see.

    Thank you

  • Multiple lines in a single column in an SQL statement

    Can someone provide me with a simple sql that runs on the underside of the table (USERROLE table)

    ID ROLEUSER ROLENAME

    1 user1 GL
    User2 OBI_AP 2
    User1 3 OBI_AP
    User2 4 GL
    User1 5 OBI_AR
    User2 6 AR
    7 the GL util_3

    and give the result form

    ROLENAMES ROLEUSER

    User1 GL; OBI_AP; OBI_AR
    User2 OBI_AP; GL; AR
    the GL util_3


    Thank you
    Vikram

    Hello

    There is a similar thread, you can watch: concatenate the values of column in a row

    Kind regards

  • Data in multiple lines concatenated into a single line to separate id

    Hello

    I have a t1 like this table:

    create table t1
    (number of c1,
    number of C2,
    C3 number (4.2)
    );

    Data in the table are such as:

    ----------------------------------------
    C1 | C2 | C3 |
    -----------------------------------------
    102. 1. 1.1 |
    102. 1. 1.2 |
    102. 2. 2.1 |
    103. 2. 2.1 |
    103. 2. 2.2 |
    -----------------------------------------

    How to display data by using a query above?

    ------------------------------------------------------
    C1 | C2 | C3 |
    -------------------------------------------------------
    102. 1, 2 | 1.1, 1.2, 2.1 |
    103. 2. 2.1, 2.2.
    ------------------------------------------------------

    Thank you

    So you're after what we call 'Aggregation in the chain.'

    Check this link as it highlights several techniques:

    Aggregation of string techniques

    A Re: Concat ranks of the values in a single column Michael

    At Re: multiple lines in a single line in the 'single column Table' followed by reason of Billy on the conduct of a stragg first.

    In addition, 11 GR 2 has the LISTAGG function.

  • L50-A-19N satellite can not read audio data from multiple sources

    I can't read the audio data from multiple sources. It is very annoying when I have 2 youtube videos, playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 open media players and 1 youtube video playing, youtube video has no sound...
    It disappears when I plug my headphones...

    I already have all the latest drivers, the DTS driver was last updated was in 2014, his day of February of this year...






    25/02/14

    DTS Inc. Windows 8.1 - 64 Bit 1.01.2700

    I don't know if this has the feel, but I had his most recent DTS driver that I found, it is not my laptop model, but they all seem to be the same - v1.1.88.0
    I uninstalled the DTS software and still had the same problem, then it is irrelevant on its driver somehow...






    02/10/15

    Integrated Device Technology Inc. Windows 8.1 - 64 Bit 6.10.6491.0

    Audio driver IDT has more recent release date, but the version of the driver is the same as the 2013 one...
    Why the older drivers of toshiba releaseing as 'NEW '?

    2nd is my Advanced settings speakers, nothing has changed when I disabled "allow applications to take exclusive control of this device.

    Sorry but I don't understand your problem.
    I tested it on my machine and if I start the music on three different sources (YouTube, player, web radio) I can hear all together, but it makes no sense to listen to music from different sources.

    Or how do understand you?

  • map a java object to data from multiple data sources

    We have the requirement that the attributes in a domain class can come from data from multiple data sources. Is TopLink supports this type of mapping? Is it possible to do this mapping in the workbench?

    Thank you very much!

    Ming-Wen

    TopLink supports a feature of SessionBroker. This allows classes in the same session to come from different sources of data and for the relations between the classes of data sources. It does not allow a single instance of direct data from multiple data sources, but the Forum could have a link with its data in the other data source.

    ----
    James: http://www.eclipselink.org

  • Aggregation of data from multiple sources with BSE

    Hello

    I want to aggregate data from multiple data sources with a BSE service and after this call a bpel with a process of construction of these data.
    1 read data from the data source (dbadapter-select-call)
    2. read data from the data source B (dbadapter-select-call)
    3 assemble the data in xsl-equiped
    4. call bpel

    Is this possible? How can I get data from the first call and the second call to conversion data? If I receive data from the second call, the first call data seem to be lost.

    Any ideas?
    Gregor

    Gregor,

    It seems that this aggregation of data is not possible in the BSE. This can be done in BPEL too using only assigned but not using transformations. I tried to use transformations by giving the third argument to the function ora: processXSLT. But couldnot get the desired result.

    For more information on the passage of a second variable (of another schema) as a parameter to xslt pls refer to the post office

    http://blogs.Oracle.com/rammenon/2007/05/

    and the bug fix 'passage BPEL Variable content in XSLT as parameters'.

    Hope this helps you.

    Thank you, Vincent.

  • How to insert multiple lines using a single query

    Hi all

    How to insert multiple lines using a single query to the emp table?
    I have the number of rows to insert into table x. consumes a lot of time. I tried to insert several lines using a single query, but get errors. I know exactly the query to do this.


    Thank you
    Sunil

    Like this?

    SQL> create table test(id number , dt date);
    
    Table created.
    
    SQL> insert into test values(&a,&b);
    Enter value for a: 1   --- It asked me and I entered 1
    Enter value for b: sysdate  --- It asked me and I entered sysdate
    old   1: insert into test values(&a,&b)
    new   1: insert into test values(1,sysdate)
    
    1 row created.
    
    SQL> 
    

    g.

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • value of multiple line in a single row (nclob)

    Hello
    I have a requirement where I have to work on a nclob data type column, now here the value of 2 lines in a single column. Like this:

    Select extractvalue (xmltype (details), '/ Anything/invoiceNumber') separate as invoices,
    actinguserid as user_id, createdt
    of bchistevent where bucket = 201301
    and upper (type) = ' COM. AVOLENT. PRESENTATION. EVENT. INVOICEDOWNLOADEVENT'
    - and bchistevent.bucket = to_char (add_months (sysdate-1), "YYYYMM")

    000-395452969-20130103 1.46388193452398E37 08/01/2013 03:05:42
    300000590-000-20090723 1.46388193452398E37 11/01/2013 08:11:45
    300000590-000-20090723 1.46388193452398E37 11/01/2013 08:12:50
    000-395453127-20130103 1.46388193452398E37 14/01/2013 04:44:26
    * 300084670-000-20120906, 300084671-000-20120906 * 1.46388193452398E37 07/01/2013 12:45:19 AM
    000-395452626-20130103 1.46388193452398E37 08/01/2013 03:03:57
    000-300084679-20120906-1.46388193452398E37 11/01/2013 08:10:47
    300000728-000-20090731 1.46388193452398E37 11/01/2013 08:19:19
    000-300084679-20120906 1.46388193452398E37 14/01/2013 12:31:48 AM
    300000590-000-20090723 1.46388193452398E37 14/01/2013 04:13:19
    000-395452718-20130103 1.46388193452398E37 08/01/2013 07:10:19
    000-300084679-20120906 1.46388193452398E37 23/01/2013 06:54:11
    000-300084679-20120906 1.46388193452398E37 22/01/2013 03:11:54
    300000590-000-20090723 1.46388193452398E37 11/01/2013 08:14:02
    000-395453127-20130103 1.46388193452398E37 14/01/2013 04:33:12
    000-300084679-20120906 1.46388193452398E37 22/01/2013 03:03:36
    000-300084679-20120906 1.46388193452398E37 14/01/2013 12:34:13 AM
    000-395452997-20130103 1.46388193452398E37 07/01/2013 03:31:38
    000-395452391-20121027 1.46388193452398E37 03/01/2013 04:40:05

    and the value of the "BOLD" highlighted line is coming in a single line, please help how to break this in 2 rows?

    Published by: user1175303 on March 13, 2013 05:43

    user1175303 wrote:
    the value of the column that is involved is 300084670-000-20120906, 300084671-000-20120906 here I get 2 values in a single column, and for this reason, I am unable to get the desired result.

    If you have XML question but try to solve in Oracle? Why is the owner of two invoice numbers? In any case:

    with t as (
               select  distinct extractvalue(xmltype(details),'/Anything/invoiceNumber') as invoices,
                       actinguserid as user_id,
                       createdt
                 from  bchistevent
                 where bucket = 201301
                   and upper(type) = 'COM.AVOLENT.PRESENTATION.EVENT.INVOICEDOWNLOADEVENT'
              )
    select  regexp_substr(invoices,'[^,]+',1,column_value) invoices,
            user_id,
            createdt
      from  t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(regexp_replace(invoices,'[^,]')) + 1
                               )
                       as sys.OdciNumberList
                      )
                 )
    /
    

    SY.

  • Convert multiple lines in a single value separated by commas

    Is is possible to convert multiple lines in a single value by concatenating the value of each line in OBIEE. I think that IO had seem a blog related to this by I'm not able to find him. Essentially, here's what I would do:
    Number of customer location
    101
    101 NY
    101 PA
    102 TX
    102 CA

    This is to convert
    101. HE, NY, PA
    102 TX, CA

    Can you get it someone please let me know if this is possible and how to operate it.

    Thanks in advance for the help.

    You can do this by creating a DB function,

    Visit this link
    Re: Display of the horizontal values

    Thank you
    Vino

  • How do I rotate my result of a query from a line to a SQL column?

    Hey, guys:

    Is it possible that I can rotate my result of a query from a line to a SQL column?

    It's a certain type of pivot example
    Instead of
    DEPTNO DNAME
    -------- ---------------
    10 accounting
    It would be
    DEPTNO: 10
    DNOM: ACCOUNTING

    Hello

    When you have N columns to rank 1 and you want to display in the form of 1 column on several lines, it's called Unpivoting . Here's a way to do it:

    WITH     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 2     -- number of columns to be unpivoted
    )
    SELECT     CASE c.n
             WHEN  1  THEN  'DEPTNO'
             WHEN  2  THEN  'DNAME'
         END || ':'        AS label
    ,     CASE c.n
             WHEN  1  THEN  TO_CHAR (d.deptno)
             WHEN  2  THEN  d.dname
         END || ':'        AS val
    ,     d.deptno               -- PK, if needed
    FROM         cntr        c
    CROSS JOIN  scott.dept  d
    WHERE   deptno = 10               -- or whatever
    ;
    

    The query above works in Oracle 9.1 or more.
    From Oracle 11.1, you can also use the SELECT... Function of the UNPIVOT operator.

  • Data from multiple rows in single line in BI publisher 11g

    Hello

    I receive documents in multiple lines

    for example

    ID case1, case3 CAS2

    1 C1

    1 C1

    1                 C2

    1                              C4

    Now, I want to make it as a single line, output desired is

    ID Case1, Case3 CAS2

    1 C1 C2 C4

    is it possible, please let me know.

    Thanks in advance

    Kind regards

    Sam

    He seems to do at the level of the model.

    Could you please post your example of xml data?

  • How to handle data from multiple fields

    Hi all

    My data are:
    FldName           FldTypeCode          Text
    Sandya            02                         nothing
    Raj                 01                         12/Oct/2008
    Lokesh            03                          12546
    Harish             04                          12565.35
    King                01                          12/Nov/2007
    Cobra              02                          texttype
    In the user interface, I give all the data of three fields with refcursor. now in HQ DB happening all the values to be updated at the same time.
    (Q) now my question is how to update all values.
    For example: create procedure procdname (ip_allvalues in typerecord)
    is
    Start
    -statements;
    end;

    the procedure input parameter above can manage all data from three fields as they pass.
    (1) if the parameter handle, should what kind I create?
    (2) I need how can I update multiple records at once?

    Please can any body...
    Thanks in advance...

    sanjuv wrote:
    But when it goes to day it must pass all records at once (lines have almost 55) at a time not possible to update for all records but also not good to create input parameters for the procedure 55. If it has past a table how can I handle this situation.

    Why do you need to update all records at once? And what is blocking you implements a loop on the user interface which, for each changed row, submits an update of the DB? Note that you will get no improvement with a bulk operation when entering comes from a user interface.

    Alessandro Bye

Maybe you are looking for

  • Use folders to organize your bookmarks

    No "new folder" in Firefox on OS X 10.6.8 (can't access "On Firefox" while it is open?)

  • I Pod Nano defective

    I have an I Pod Nano 7th generation is probably 8 or 9 years old.  It's worked perfectly without any problems.  I used it yesterday and put it on the charger, last night.  I got it this morning and it wouldn't turn on so I plugged it to my computer a

  • You have asked firefox to connect safely

    So I just reinstalled Firefox and I started having this problem with some Web sites. (GoogleMail, Facebook, most of the sites https.) Here is the error: You asked Firefox to connectfirmly to facebook.com, but we cannot confirm that your connection is

  • Impossible to replace and update a file in the client computers through Group Policy preferences

    Hello I am unable to replace and update a file in the client computers through Group Policy preferences. For example,. I am trying to replace and update a custom calendar file (c:\Program Files\Microsoft Office\Office12\1033\outlook.hol)to client com

  • Problem with VPN connection via a wireless card broadband Verizon Cisco VPN air

    I can't access any device on my network via RDP or applications via the host file - forwarded servers from my 64 bit Windows 7 laptop using wireless broadband Verizon and customer VPN Cisco 64 bit 5.0.7.290. I can connect easily via a LAN wired conne