Solved

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

Posted on 2007-03-25
1
412 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
Comment Utility
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.

Join & Write a Comment

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

771 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

14 Experts available now in Live!

Get 1:1 Help Now