Solved

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

Posted on 2007-03-25
1
414 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
1 Comment
 
LVL 15

Accepted Solution

by:
OMC2000 earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now