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
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
Messages: 25581
Registered: January 2009
Location: SoCal
Senior Member
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: 65155
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).

Previous Topic: DBMS_ROWID and IOTs
Next Topic: Pack decimal
Goto Forum:

Current Time: Thu Aug 24 02:02:01 CDT 2017

Total time taken to generate the page: 0.09636 seconds