?
Solved

Query Help

Posted on 2011-03-10
4
Medium Priority
?
289 Views
Last Modified: 2012-05-11
Hi,
  Please find the attached file for the table export data. It has id, name and containingregion columns.
containingregion column has id which connects to other location in the same table.

My problem here is  when I give an id I need to get country for that id and continent for that ID in two queries. my problem here is some times the ID might be county record, some times the ID might be state ID..when I give ID I need to get country, state and continent. if the id is country id, then I need to get state as null, country as this record and continent should be the continent of the record.

I need it in three queries, one for state, one for country and one for continent. Please let me know how can I do it.

Thanks
table-export.xls
0
Comment
Question by:Sthokala
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Akenathon earned 750 total points
ID: 35096983
Please post your expected results as a spreadsheet, it's difficult to follow the written explanation.
0
 
LVL 2

Assisted Solution

by:swadhinray
swadhinray earned 750 total points
ID: 35124932
Name is the country name what you are expecting but I think there should be one more table containing your location and continent information.

Boz one continent can have multiple location and you location which ID in your file should always be unique so based on that you need to make a relation and get the expected result and as Akenathon: said to provide a expected result then it will be easier to understand what you are looking for as when i did a select on each ID I am able to get the result like below:

ID      NAME      REGIONCODE      CONTAININGREGION      STATE_PROVINCE_IND      REGION_TYPE
3975      United States      US      3965      N      CNTRY


Which seems to be a good data.

Better to provide a expected result you are looking for.
0
 

Author Comment

by:Sthokala
ID: 35131315
Thanks Guys for your rsponse. I found the solution for this.
0
 

Author Closing Comment

by:Sthokala
ID: 35131330
Found solution
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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…
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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