Parent - relationship of the child in a table

Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

I have the following table. The table contains an attribute called parentraid that specifies if it is a parent or a child. For the data indicated below, ra1, ra2, ra3 are parent and others are children with their respective parents specified in the parentraid attribute.
CREATE TABLE  "ADDRESEARCHAREA" 
   (     "RAID" VARCHAR2(30) NOT NULL ENABLE, 
     "RANAME" VARCHAR2(30), 
     "RASTARTDATE" DATE, 
     "RAENDDATE" DATE, 
     "PARENTRAID" VARCHAR2(30), 
     "RASTATUS" VARCHAR2(30), 
      PRIMARY KEY ("RAID") ENABLE
   )

insert into addresearcharea values ('ra1','raname1',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra2','raname2',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra3','raname3',to_date('04/01/2012','mm/dd/yyyy'),'','','Active')
insert into addresearcharea values ('ra4','raname4',to_date('04/01/2012','mm/dd/yyyy'),'','ra1','Active')
insert into addresearcharea values ('ra5','raname5',to_date('04/01/2012','mm/dd/yyyy'),'','ra2','Active')
I am looking for the following output,
RAID RANAME PARENTRAID PARENTRANAME 
ra1 raname1 -  -  
ra2 raname2 -  -  
ra3 raname3 -  -  
ra4 raname4 ra1 raname1  
ra5 raname5 ra2 raname2  
Help, please

Try this

select a.RAID as RAID, a.RANAME as RANAME, b.RAID as PARENTRAID,  b.RANAME as PARENTRANAME
from ADDRESEARCHAREA a
left join ADDRESEARCHAREA b
on ( a.PARENTRAID=b.RAID)
order by 1 

And thank you for providing the Insert table ddl and sample

Edited by: Anupam_Halder to add aliases to the column

Tags: Database

Similar Questions

  • Disable the parent window when the child window is open

    Hello
    I need to open a new popup window using javascript .i don't want adf use predefined function such as dialog, _target, usewindow (according to the req) .but I can able to open a pop-up window, but parent window is still active (not disabled) I'm clicking on parent window when the child is open.

    what I did:

    (1) I used in light of the fn on the onclick event of the command button

    < script type = "text/javascript" >
    var popupWindow = null;
    function popup() {}
    popupWindow = window.open ('http://10.14.1.1:9002/a/b/c/d/payment/Settlement.jsp','abcd12','height=600,width=600,top=0,left=0,resizable');
    popupWindow.focus)
    }

    < /script >

    give me good suggestion to solve this problem

    Siva,

    A quick google search revealed that the behavior you're seeing is an expected behavior of the modal dialog box.

    See if the given suggestion [this post | http://www.experts-exchange.com/Web/Q_20832231.html] help.

    Jean Lou

  • Parent index for the data in a table?

    Is there a way to index a child table with a function to include a column from a parent table?

    Example:

    I want to see how many children live in a zip code (and their address is listed with their parents)

    Select count (*)

    class c of child, parent p

    where c.parent_id = p.parent_id

    and p.zipcode = "12345"

    Is there a way to make an index of children with a function that gets parents zip code?

    Thanks for the help?

    An index on the child table can reference only the columns of the child table.  You can't have an index on the child table that is based on information from the parent table.

    There are the function-based index, but they may involve only constants and deterministic functions (and, of course, the columns of the table).  For example, the child table could have a clue on UPPER (name), where last_name is a column of the table, but he could not have a clue about get_zip (parent_id), where get_zip is a function defined by the user who queries the parent table.

    Well - you "might" have a functional indication if you did to be deterministic, but it is not recommended because if the changed zip_code parent would really not deterministic and the change would not be included in the index.

    This apart from this code will work properly if the zip_code data does not change:

    CREATE TABLE parent (COL1 number primary key, zip VARCHAR2 (5))
        
    create the child table (col1 number, parent_key number);

    create or replace function get_zip (number p_key) return deterministic varchar2 as
    v_zip varchar2 (5);
    Start
    Select zip from v_zip of the parent where col1 = p_key;
    Return v_zip;
    end;

    /

    create indexes on children (get_zip (parent_key)) child_zip;

  • Private data LVOOP Parent returned when the child instance created from constant

    I created a parent class and child class.  For each of these classes, I created a member who is a builder, whose purpose is to initialize constants for each class and return the instance of the class VI.  I also have an accessor Member VI for each class that returns private data of the class (in this case, a single string for each class).

    Private class data Parent 'String' is set to "text Parent" as default.

    Private data of the class of the child 'Child String' are set to 'Child text' as a default.

    The Parent class constructor works very well.  For testing purposes, I'll be back the text of unbundling of directly the manufacturer VI, as a return of the VI accessor. The Parent constructor starts from a class constant.

    However, in the case the constructor of class as a child, if I start from a class constant, unbundling directly private data (using a feature of unbundling by name and choosing "Child String" as the element), I get the private parent data!

    If I use the Member of the class of the child VI to retrieve the text, I get the private data of the child.

    If I change the constructor from a class of control instead of a constant class, I get the private data of the child.

    This occurs only until the child class has existed as a control flag. that is, if I ungroup private data, after the class is returned by any Member VI, I get the private good child data.  Then, of course, something changes once the class 'data' has been a control at a given time.

    I'm using Labview 8.6.1, Windows XP

    I have attached a small project that demonstrates the problem that I encounter, without actually doing initialization, just read.

    Is this expected behavior?  Why does it matter if I start with a constant of class instead of a control of the class?  When you slide the block diagram in the project window, you will always have a constant.

    Although I was able to reproduce your problem in LabVIEW 8.6.1, it seems to work fine in 2009.  I could not find a CAR ID, but at this point I can only assume that the behavior was not intended but it is set in 2009.

    Let me know if you need me to find more details.

  • The child role of Table name in IOM comes blank

    Hello

    I work with connector DBAT and do a reconciliation of the target users are held properly and data reconciliation is also visible in the case of reconciliation, but the question is, the role name is not visible or an empty value is entered in the child table.

    There are no errors in newspapers.

    Is there something that I missed during the configuration. ???

    I ran the planners for the reconciliation of the search and list of rights once again, but still no luck.

    Everyone faces the similar question, or how I can fix this problem.

    Thanks in advance.

    Concerning

    Ritesh Maddala

    Hello

    I've updated the solution here - Oracle Identity Management Help Engine of Ritesh: entry in the Child Table IOM - reconciliation target - is coming Blank.

    Concerning

    Ritesh Maddala

  • Display parent next to the child in the row header

    Hello-

    I have a dimension in a cube of ASO, who has dozens of children for each of the thousands of parents. I'm writing a report of financial information that indicates the members of level 0 and displays their name of the mother next to them in the report rows (these names parent would be descriptors for the benefit of the user - data will still be level 0). I'm not able to find any variation of MemberProperty in a text column that can do this, nor any formula in the row header. I plan to redraw the cube to these children and their parents in separate dimensions, but fighting which makes sense to me, because they have a perfect parent/child relationship. Can anyone suggest a way around this? I thank very you much for your time.

    -Rob

    Have you considered creating another table of aliases that concatenates the Parent and child for the Alias.

  • relationship between the oe_headers and mtl_material tables

    Hello

    can anyone guide me with the link between
    oe_order_headers_all oeha,
    mtl_material_transactions and oe_order_lines_all extreme
    is that correct?

    OELA.line_id = mmt.transaction_source_id
    AND oela.header_id = oeha.header_id
    pls Guide

    Published by: makdutakdu on March 2, 2011 12:06

    Hello

    This join is not correct.
    The ID of the header is not same as transaction source line id.
    But line id is the same as the transaction source line id

    Select order_number in the oe_order_headers_all where header_id in
    (select header_id in the oe_order_lines_all where line_id in)
    (by selecting TRX_SOURCE_LINE_ID in Mtl_material_Transactions)
    )

    Kind regards
    Sabari

  • Responsive HTML5 with mergedprojects, creates a hyperlink to a file in the project html parent to a child html file and it does not work! The child has with the parent TOC, but need to tie. Help, please!

    Hi group!

    I have a brilliant parent project that serves as a springboard for other projects. Users click a component of software they want and are redirected to a page with a list of all the documentation available for this component. Click on the name of a document and access - a lot of PDF files. BUT I also wish they were able to tie the online help for the component. After having read up on the link through / between projects, I knew that I needed to create a parent project (for the page intro and links brilliant) and projects for children (for software components).

    THEN

    I created a parent sensitive HTML5 project and the projects of two children. I compiled the parent to create mergedprojects files, and then open the projects children and collected to the appropriate mergedprojects folder. I then created a hyperlink to the file list html documentation in the project parent towards the child file software component html (output folder and start page [which is the same as the default theme]) and the link does not work! The child and its table of contents appears in the parent TOC so topics are here, but I can't link to them. If necessary, I can send screenshots.

    Where I am dorking this place?

    Thanks in advance for your time and help!

    Scottie 'needs help' gear

    What is your relationship like? And how did you create the link?

    A typical reactive merged help is structured as follows:

    index.htm (Master home page)

    mergedProjects

    childName

    index.htm (starting page for child)

    A child from the index.htm page link would look like this:... /... index.htm

    Kind regards

    Willam

  • SQL to align the values of the child with the parent columns

    Hello world

    I'm stumped on how to develop a sql query that generates a report which my child values are aligned with my columns parent based on corresponding years.  Here is an example...

    create table test_yr (yr_id number primary key, yr_nb number);
    insert into test_yr values (1,2013);
    insert into test_yr values (2,2014);
    insert into test_yr values (3,2015);
    
    create table test_parent (parent_id number primary key, parent_yr_id_begin number, parent_title varchar2(100));
    alter table test_parent add foreign key (parent_yr_id_begin) refererences test_yr (yr_id);
    insert into test_parent values (1,1,'This rec starts in 2013');
    
    create table test_child (
         child_id number primary key,
         child_parent_id number,
         child_yr_id_begin number,
         child_title varchar2(100),
         child_yr1_val number, child_yr2_val number, child_yr3_val number, child_yr4_val number, child_yr5_val number
    );
    alter table test_child add foreign key (child_parent_id) references test_parent (parent_id);
    alter table test_child add foreign key (child_yr_id_begin) references test_yr (yr_id);
    insert into test_child values (1,1,3,'This rec starts in 2015',10,20,30,40,50);
    insert into test_child values (2,1,3,'This rec starts in 2015',15,25,35,45,55);
    
    
    

    The child can begin to another to start the year as the parent, which makes different yr1 for parent and yr1 for child.  So, for this example, the child 1 year (2015) = year 3 of the parent.

    I can get the values strictly of the child using the following...

    select child_yr1_val, child_yr2_val, child_yr3_val, child_yr4_val, child_yr5_val
    from test_child
    where child_parent_id = 1;
    
    

    However, I need the report to be based on the first five years of the parent.  And since the child does not start until 2015, two years should be zero.  This is the expected result:

    Yr1 | YR2 | YR3 | yr4 | Yr5

    ---------------------------

    0   | 0   | 10. 20. 30

    0   | 0   | 15. 25. 35

    I am doing it using simple sql without having to use pl/SQL to derive a dynamic query.  But I need to somehow to the height and line up the years... like in this example, yr1 (child) = yr3 (parent), (child) yr2 = yr4 (parent), etc..  I hope that some joints and case statements will do the trick, but I don't know how to use them to get the result that I need.  Can anyone help?  Oracle 11 g 2.

    Thank you

    Mark

    Hi, Mark,.

    Here's one way:

    WITH unpivoted_child AS

    (

    SELECT child_id, child_parent_id

    child_yr_id_begin + child_yr - 1 AS column_num

    val

    OF test_child

    UNPIVOT (val

    FOR child_yr (child_yr1_val AS 1

    child_yr2_val AS 2

    child_yr3_val AS 3

    child_yr4_val AS 4

    child_yr5_val AS 5

    )

    )

    WHERE child_parent_id = 1

    )

    SELECT NVL (y1, 0) AS yr1

    , NVL (y2, 0) AS yr2

    , NVL (y3, 0) AS an3

    , NVL (y4, 0) AS yr4

    , NVL (y5, 0) AS yr5

    Of unpivoted_child

    PIVOT (SUM (val)

    FOR column_num IN (1 AS y1

    2 AS y2

    3 AS y3

    4 AS y4

    5 AS y5

    )

    )

    ORDER BY child_parent_id

    child_id

    ;

    Have 5 columns in the test_child that all say the same thing, obly for different years, isn't a very good design table.  It wouyld be better to have a single table for all the attriburtes that apply to the child and another table for each combination of year, with a single amount on each line.  Because you don't have that, the unpivoted_child of the subquery, it essentially creates on the fly.

  • We can the child resource form field map table to child form process?

    Hello

    Can map the child field to the resource form table to process child table field?

    Tab in the process definition data flow, I tried to map the field of resource child form tabel with th treat the child form field table... but there is no available for this option.

    However, add a data flow Table mapping we can match child table resource to the child shape process table but that doesn't sovles my problem.

    Please provide any pointer

    Once you map the table, you right-click in the table and map fields from the child. According to me, this is how it works, or select the table mapping and click Add field. One way or another, you need to add the first table, and then the field.

    -Kevin

  • Permission of the child

    Summary of the issue
    Other issues of the Windows Live ID

    Please provide your address affected:
    E-mail address is removed from the privacy *.

    Additional details
    I have accounts of electronic mail for my 2 children and had their accounts set to have me give permission whenever they wanted to add a friends email address.  My daughters are now old enough that I would like to remove this feature.  However, I have difficulty finding ways to remove the feature.  I don't remember how I have set up in the first place.  Can someone help me?

    Hi the rules of Softball,

    To remove the account from the child that is managed by Windows Live Family Safety. You must delete the child's account in fss.live.com using the parent account and uninstall the client of Windows Live family safety on their computer. To do this, please follow the steps below:

    A. remove the child in fss.live.com account

    1. connect to http://fss.live.com using the parent account.
    2. click on the remove a member of the family link.
    3. check the box for the account you want to delete.
    4. click on the Remove button and confirm the deletion.

    B. uninstall your Windows Live parental control over the child's computer to delete the current settings.

    Uninstall Windows Live Family Safety

    Let us know if you need more assistance.

    Thank you!

  • Relationship between the user and account in IOM DB

    Hello

    do you know how is set up the relationship between the user's record in the USR table and an account of application instance in the table form of process (as in UD_LDAP_USR)? I analyzed records from both tables, but failed to find the key to the relationship between the records in these tables.

    Peter

    The table Ouedraogo is the link between all the tables of an instance of a resource. The ORC_KEY is the process instance key that links the tables of UD_XXX. And there is also the USR_KEY which connects to the table user.

    -Kevin

  • How to find the child of the request id for a given simultaneous request id.

    Hi all
    I'm having a concurrent request id. How can I find any child request ID it can be seen.


    Thank you

    Please see these documents.

    REQUESTS.sql Script for Parent/child request ID and Trace File [280295.1 ID]
    How to check the Dates at the end of a concurrent request of Parent and all the child processes [ID 751438.1], start and list

    Thank you
    Hussein

  • Delete form for the child process data

    Hello

    I have a form of child process for my multivalue attributes. I would like to delete one or more entries from the shape of child process via the API data, but the only API that I found was removeProcessFormChildData. But I guess this method deletes all data in the form of child process. Is there an other API I can use? How to remove the child process form data?

    Thank you
    PETREA

    See this thread for an example of code:

    Re: How to remove the child form data table

    For more examples, just look for the api and you should be able to present to a code example.

    -Kevin

  • LVOOP - 1 table of Parents in several bays of the child?

    I have 3 types of channels in my system. DI, I and AO.

    I want to create a Parent class that has 3 children for each of my types of channels.  It's because I want to store (on disk using flatten chain) all my channels together as an array of strings.  It's ok because I can use the 'to the more generic class"and a record in a table of my parents (CHANNEL class).

    The problem is when I read this array of objects.  I can read my array of objects parent but then I want to transform my array of objects of string into an array of objects, an array of objects HAVE and an array of objects of the DI AO.

    Any ideas?  Thank you.

    Lewis_G wrote:

    Hi nathand thanks for the ideas.  I've implemented it as you sugested.  Is there a way to make it more scalable?

    You might abuse the primitive preserve Run-Time class, as shown below. This divided the table parent tables separated for each class of the child, but the type of each element of these tables is always the parent type, even if they are transporting children. Not sure if that's what you want, or not.

    Lewis_G wrote:

    The child the more classes i, messier, fine.  Even if the code is the same for both, I can't have a Subvi generic because the child class is different for the two.  Don't you think it's a good idea to have a new class of table for each child.  For example, I could make a class with a method that has a channel enter parent and trys to add it to the guard?

    This could be very good, if it meets your needs.

    Intaris wrote:

    nathand wrote:

    Otherwise, add a method to the class called parent Type Get and override it in each class of the child, and then call on each element of the array to determine its type.

    And make sure that the type is a string, otherwise problems ensure later in life...

    I thought to mention that when I offered everything first, but then I thought that there could be situations in which an enum would work very well if you don't mind violating good OOP practices. Yes, the parent should know his children and you need to know about all children at design time, but if you can accept these terms then an enum is simple. I'm undecided about whether I would never apply this solution if I were to try to solve this problem in my own code.

Maybe you are looking for