Home » SQL & PL/SQL » SQL & PL/SQL » Parent - Child query (Oracle 10g)
Parent - Child query [message #341122] Sat, 16 August 2008 17:46 Go to next message
eagyeman
Messages: 6
Registered: May 2007
Junior Member
I have a table that has parent and child information. The columns
are site_id, parent_id and machine_id. The parent site has parent_id which is null and the child's site_id will have a parent_id of the site_id of one of the parents.

I am trying to retrieve a count of machine_id of the parent sites which should include a machine_id count of its children. So if parent A has a machine_id count of 1 and child B has a machine_id count of 2 and child C has a machine_id count of 3 then I want to retrieve the parent A machine_id count of 6.

I hope this is clear

Re: Parent - Child query [message #341124 is a reply to message #341122] Sat, 16 August 2008 18:52 Go to previous messageGo to next message
BlackSwan
Messages: 25042
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW the Posting Guidelines as stated in URL above
Re: Parent - Child query [message #341137 is a reply to message #341122] Sun, 17 August 2008 00:36 Go to previous message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post a test case: create table and insert statements along with the result you want with these data.


Post what you already tried and why it does not work.

Before, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: can some explain me in detailed how the below query works
Next Topic: DBMS_ROWID and IOTs
Goto Forum:
  


Current Time: Tue Dec 06 15:52:03 CST 2016

Total time taken to generate the page: 0.10512 seconds