Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

showing a sub hierachy in a main hierarchy query using connect by prior

Posted on 2007-03-25
1
Medium Priority
?
422 Views
Last Modified: 2013-12-19
folks

here is a hierarchy in oracle

SELECT LPAD(' ',2*(LEVEL-1)) || TO_CHAR(location) s
  FROM location
  START WITH location ='12000'
  CONNECT BY PRIOR location = parent;

AS  you see the table is called location,my asset table also has its own hierarchy,but in affect has a relation to the location table location.location =asset.location,below is its own hierarchy
 
  SELECT LPAD(' ',2*(LEVEL-1)) || TO_CHAR(ASSETNUM) s
  FROM asset
  START WITH assetnum ='AGV314'
  CONNECT BY PRIOR assetnum = parent;

 how do i join both selects?to show all locations as all its assets in one hierarchical query?

all help will do
0
Comment
Question by:rutgermons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
OMC2000 earned 2000 total points
ID: 18791100
SELECT location, a.s,  b.s FROM
(SELECT location, LPAD(' ',2*(LEVEL-1)) || TO_CHAR(location) s
  FROM location
  START WITH location ='12000'
  CONNECT BY PRIOR location = parent) a
LEFT OUTER JOIN
(SELECT location,  LPAD(' ',2*(LEVEL-1)) || TO_CHAR(ASSETNUM) s
  FROM asset
  START WITH assetnum ='AGV314'
  CONNECT BY PRIOR assetnum = parent) b
ON a.location = b.location

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question