dbTalk Databases Forums  

SQL Challenge, My Brain is dead on this...

comp.database.oracle comp.database.oracle


Discuss SQL Challenge, My Brain is dead on this... in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Anand
 
Posts: n/a

Default SQL Challenge, My Brain is dead on this... - 01-20-2004 , 01:52 AM






Hi All,

I have a Geographic parent/child relationship table with the following
columns.

Geographic_Units
-------------------
Geo_Unit_Code (PK)
Geo_Unit_Name
Geo_Unit_Type
Parent_Geo_Unit_Code


And Sample Data is as follows.
Geo_Unit_Code Geo_Unit_Name Geo_Unit_Type Parent_Geo_Unit_Code
------------- ------------------------- ----------------
----------------
WRLD WHOLE WORLD WORLD (null)
NA NORTH AMERICA CONTINENT WRLD
EU EUROPE CONTINENT WRLD
USA UNITED STATES OF AMERICA COUNTRY NA
CAN CANADA COUNTRY NA
SPN SPAIN COUNTRY EU
FNL FINLAND COUNTRY EU
AZ ARIZONA STATE USA
OH OHIO STATE USA

In a hierarchical form, it is as follows:
WORLD
NORTH AMERICA
UNITED STATES OF AMERICA
ARIZONA
OHIO
CANADA
EUROPE
SPAIN
FINLAND

There is an employee table having a Geo_Unit_Code column referencing
to the Geo_Unit_Code of the Geographic_Units. Now I have to write a
query which will give me employee information for each continent.

So my final result set should contain the continent name and employee
id(the PK in the Employee table).

Can any one help pls?? I am newbie in oracle. Figuring out how to use
the "Connect by" clause for this query.

TIA,
~Anand

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.