Join two Connect By Prior Start With trees and return only common records?

Oracle 10g Release 2 (10.2)
I have two tables that have tree structured data. The results, when running the queries individually are correct, however I need to join tree one to tree two in order to obtain only the common records between them.
-- Tree one
SELECT ip_entity_name, entity_code, hier_level, entity_parent
FROM ip_hierarchy
WHERE hier_level >= 3
CONNECT BY PRIOR entity_code = entity_parent
START WITH entity_code = 'MEWWD';
-- Tree two
SELECT ip_entity_name, entity_code, hier_level, entity_parent
FROM ipt_hierarchy
WHERE hier_level >= 3
CONNECT BY PRIOR entity_code = entity_parent
START WITH entity_code = 'IPNAM';
As I understand, joins may not work with CONNECT BY/START WITH queries?
Is a WITH clause an option?
If at all possible, I don't want to put one select in a View database object and join against the other query.
Thanks.

Hi JTP51,
You can use WITH clause or sub-query by using in-line view, without creating any view object in database.
for example
SELECT A.IP_ENTITY_NAME, A.ENTITY_CODE, ....
  FROM (SELECT IP_ENTITY_NAME, ENTITY_CODE, HIER_LEVEL, ENTITY_PARENT
          FROM IP_HIERARCHY
         WHERE HIER_LEVEL >= 3
        CONNECT BY PRIOR ENTITY_CODE = ENTITY_PARENT
         START WITH ENTITY_CODE = 'MEWWD') A,
       (SELECT IP_ENTITY_NAME, ENTITY_CODE, HIER_LEVEL, ENTITY_PARENT
          FROM IPT_HIERARCHY
         WHERE HIER_LEVEL >= 3
        CONNECT BY PRIOR ENTITY_CODE = ENTITY_PARENT
         START WITH ENTITY_CODE = 'IPNAM') B
WHERE A. ENTITY_CODE = B. ENTITY_CODE
AND ....Best regards,
Zhxiang
Edited by: zhxiangxie on Feb 2, 2010 5:35 PM

Similar Messages

  • Connect BY, Prior, Start clause

    I want to understand how does the Connect BY, Prior, Start clause work, i mean the concept.
    Please explain with an example.
    I hope, my question is clear. Please help in solving the doubt as it is urgent.
    Regards.

    Here is the simple example you can find in a dept first traversal fashion the records come in mgr-emp hirarchy
    SQL>SELECT * FROM EMP
      2  START WITH MGR IS NULL
      3  CONNECT BY PRIOR EMPNO = MGR;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTN
          7839 KING       PRESIDENT            17-NOV-81       5000                    1
          7566 JONES      MANAGER         7839 02-APR-81       2975                    2
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    2
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    2
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    2
          7369 SMITH      CLERK           7902 17-DEC-80        800                    2
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    3
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600                    3
          7521 WARD       SALESMAN        7698 22-FEB-81       1250                    3
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250                    3
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500                    3
          7900 JAMES      CLERK           7698 03-DEC-81        950                    3
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    1
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    1

  • I have very thin, colored lines running vertical on my desktop monitor screen.  I don't know where they come from or how to get rid of them.  I started with one and now have three.  Can anyone give me some insight about what to do in getting rid of them?

    I have very thin, colored lines that have shown up on my IMac monitor screen.  I don't know where they came from or how to get rid of them.  I'm concerned now because I started with one and now have three.  Does any know why this occurs or how to get rid of them?

    I got an address from Applecare, although I can't place my hand on it right now. I didn't bother persuing the letter route myself as I didn't expect much. I know that the location was Cork, Ireland though as that where the UK Applecare is based as far as I'm aware. The best thing to do is to call Applecare (if it's free) and discuss the issue. State that you are not happy wit the fact that you will have to pay to have the problem resolved especiiay if it is an ongoing problem that has not been resolved. I ended up speaking to a senior manager of the Applecare team who then proceeded to tell me about mailing in my grievence to customer services division or something like that.
    If I can find the address I may post it if I'm allowed.
    In the case of age, Schools usually have a 5-year life-cycle as they tend to be used differently than consumer machines, i.e. being used constantly on a daily basis for at least 12 hours with no break. you would expect issues to appear after a few years, but I expect problems that arise through defects to be resolved and stay resolved. As I mentioned we had machines for around 2 years before the lines appeared and sent them to be repaired. I'm happy with that. What I am unhappy about is the fact that the problem has reappeared exactly in the same way and now I'm left with around 7 machines that I either pay loads to repair or, the more likely replace the machines with newer ones since the age is now big enough to warrant the replacement.
    Sorry for the lengthy moan, but these are the reasons I purchased Apple ahrdware in the first place to avoid the "not our problem" stance some PC vendors  usually take, similar to the Dell monitors thread mentioned in here somewhere.

  • I have two Apple IDs - one associated with iPad and iPhone and the other associated with iMac and MacAir. I am going to lose the former e-mail address imminently and would like to associate all devices with just one ID. How do I do this? Thanks

    I have two Apple IDs - one associated with iPad and iPhone and the other associated with iMac and MacAir. I am going to lose the former e-mail address imminently and would like to associate all devices with just one ID. How do I do this? Thanks

    Thanks - I guess it is like there were two of me!
    I bought the iPhone first and it seemed natural to link it to the (work) e-mail address which was in constant use. The iMac for home use came next and it seemed natural to use my home e-mail address, particularly as I knew by then that I would lose the work address after my imminent retirement. The same logic went for the recent puchase of the MacAir. I am not sure what happened with the iPad (also a recent purchase) - iTunes seemed to puch me towards the same ID as the iPhone.
    It is not a huge problem - just makes my persona look schizoid! Otherwise very happy with everything Apple.

  • Sync session failed to start with itunes and iphone 5

    sync session failed to start with itunes and iphone 5

    Restart your computer
    While your computer is restarting, clear all of the applications from the background on your iPhone. You can do this by pushing the home button twice and swiping the programs off the screen by pushing them upwards.
    After you are done doing that, restart your phone.
    Wait about 10 seconds or so and turn your phone back on. By the time you get your phone back on your computer should be completly restarted and ready to go.
    When your phone is back on, plug it into your computer. This should automatically bring up your Itunes, you may get another pop up that says autoplay, you can close that out. That's it. I hope it helps and good luck

  • Not allowing to create field starting with underscore and numbers

    Hi All
    I'm trying to create a datatype in PI 7.1 with element starting with underscore and numbers like _Name , 1.0.Name. when I'm trying to activate the dataype. I'm getting the error Activation of the change list canceled.please help me out
    Thanks in advance.

    What exactly are you viewing in production - a data type? You could be viewing an external message. Reconfirm.
    rgds
    gab

  • Four digit numbering system starting with 0001 and not just 1.

    How can I re name and renumber  a file of photos and include a four digit numbering system starting with 0001 and not just 1. I need this so another computer program can keep the images in numerical order
    Now I number a wedding say... Smith_Jones 1 ect up to 659 but a program I use to create albumes scrambles all my photos becasue they say the numerical system has to have 4 digits so Number 1 is really 0001 thus staying in order.  I d ont see how to assign 3 zeros to the front of numbers --- so # 344 would be 0344  LR wants to keep it 344.

    In the Library rename use the following custom settings.

  • My Mac Book pro recently started in safe boot mode and ever since I have had endless problems - To start with the keyboard will only input capitals and symbols althougth no locks are on and now I have a green wave on all white backgrounds! HELP!

    My Mac Book pro recently started in safe boot mode and ever since I have had endless problems - To start with the keyboard will only input capitals and symbols althougth no locks are on and now I have a green wave on all white backgrounds! HELP!

    Hi it's puzzled of Evesham....I didn't ask the question but have experienced exactly the same. I switched the computer on and it went straight to safe mode

  • All MacBook Pro, iMac purchase in 2012 bug! starting with mine and those of all in Fnac st Lazare (France), try to open the keychain you will see ...

    All MacBook Pro, iMac purchase in 2012 bug! starting with mine and those of all in Fnac st Lazare (France), try to open the keychain you will see
    I've tried to open keychain first from my macbook pro because of Safari and Chrome, they still dont work in wifi unless Firefox, then I went to a Fnac (like Best Buy) and I try to open the keychain in all the iMacs exposed and everytime the application froze , to the macbook air at  the iMac all of them froze.

    Hello Kavans,
    Thank you for the details of the issue you are experiencing with your MacBook Pro.  I recommend reviewing the following article for this issue:
    Mac OS X: Why your Mac might not sleep or stay in sleep mode
    http://support.apple.com/kb/HT1776
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Hello friends , I have started with writing  c code on mac using xcode .....but one of my friend told me to use gcc for coding. He started with terminal And used a text editor to compil the c program on his mac.. So please tell me how to do the same

    Hello friends , I have started with writing  c code on mac using xcode .....but one of my friend told me to use gcc for coding. He started with terminal And used a text editor to compil the c program on his mac.. So please tell me how to do the same and is there any pre stalled text editor on mac if yes then where and if no then which text editor to install and how to install gcc...please help me out thanks in advance !!!

    I have started with writing  c code on mac using xcode .....but one of my friend told me to use gcc for coding.
    Why? If you are developing and writing code on a Mac why would you not use the tools Apple has given you? And Xcode, once you get use to it, is a very nice development environment that will make you life a whole lot easier.
    If you insist on using an editor and the terminal I would recommend  Emacs   but it has a long learning curve so  something like TextWrangler  will work too.
    As for the compiler if you have Xcode installed install the command line tools and you will be able to compile from the terminal.
    good luck

  • Get started with file and font sync

    Get started with file and font sync how do you access the 700 free fonts?

    Have you requested and received an email that you're eligible for File and Font Sync early access?
    If you have, go to creative.adobe.com and download the latest version Creative Cloud desktop after you log in with your Adobe ID.
    Then when installed, you should be able to click on Fonts to browse on the Typekit website.

  • Starts with 15fps and quickly drops to 1fps

    I don't know what changed... it has been working fine for the past couple of years. For the past couple of months my video starts with 15fps and quickly drops to 1fps -- I still receive 15fps. . I have feeling it is either my cable provider or my Vonage strangling my bandwidth (both are the same since day one) maybe some settings were changed. When I do a speed test...up and down numbers are average or above for my cable provider.
    Quicktime is set to 1.5...T1/Lan etc.
    iChat bandwidth limit is set to none (tried all choices).
    Imac G5 1.8 Ghz   Mac OS X (10.4.9)   iSight/cable/Vonage lynksys RT31P2 /Airport express

    Hi jw_17,
    Have a look at this page http://www.ralphjohnsuk.dsl.pipex.com/page16.html
    Most likely it it is a background process.
    In addition to the culprits found when Tiger came out listed on that page also open up Activity Monitor and check how many Widgets are active (shutting them down is best).
    Also check if a Print Monitor is listed as most likely this is Stuck and can be Force Quit from the button top left of Activity Monitor.
    The other possibility is that SpotLight is Indexing.
    11:10 AM Tuesday; May 8, 2007

  • Difference between IDOC segments starting with E1 and E2

    Hi all,
    What is the difference between IDOC segments starting with E1 and E2
    Thanks

    Hi Kajol,
    A segment in SAP system is technically implemented as three physically separate pieces.
    1. Segment type u2013 the version-independent name of the segment. Standard SAP names begin with E1.
    2. Segment definition u2013 contains the fields which represent the data. Its maximum size is 1000 bytes. Standard SAP definitions start with E2 with the last 3 characters implying the version of the segment.
    3. Segment documentation u2013 represents the data dictionary documentation for each field in the segment definition. It begins with E3 for SAP provided segments.
    For example, E1EDP01 will be your segment type and E2EDP01003 will be your segment definition with 003 indicating its version.By default, the segment type points to the latest segment definition.
    Kindly do reward points if you find this as useful.
    Regards,
    Aswin

  • Where do I get started with OAS and JSP ?

    Where do I get started with OAS and JSP ?
    Resources?
    Please point me in the right direction!
    Post and/or email me at [email protected]

    The simplest way is to read OAS4082 Documentation:
    Developer's Guide: JServlet and JSP Applications.

  • Pasting in Numbers cell with tabs and returns

    I am converting my old Appleworks SS files to Numbers and it works fine when I just open the .cwk file with Numbers.  But when I try to paste in to a cell text with tabs and returns, unlike AW, it puts as much of the text as will fit in one cell, truncating the remainder.
    Is there some way to change Numbers preferences (or any other technique) to push text separated with tabs to the next cell right and for returns to push to the next row?

    I just figured out what I did wrong.  The text I was pasting in was enclosed in quote marks.  Once I removed those, it pasted in perfectly, just like AW.

Maybe you are looking for