Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Selecting number of "many" in 1-to-many

Re: Selecting number of "many" in 1-to-many

From: Tim Hall <tim.hall_at_spam.begone>
Date: Wed, 06 May 1998 16:16:24 GMT
Message-ID: <35508c93.29455829@69.0.9.9>


On Wed, 6 May 1998 17:45:17 +0200, "rob" <rob_at_dsdelft.nl> wrote:

>>I'm trying to figure out how to select the number
>>of children each parent has.
>>

>select parent_name, count(*)
>from parent
>, children
>where parent.parent_id = child.parent_id
>group by parent_id;
>
>Assuming all parents have children ;-)
>

select parent_name, count(*)
from parent

         children
where parent.parent_id = child.parent_id (+) group by parent_id;

If you add an outer join, it will work even for parents who have no children.

Tim Hall, Indus International (was TSW International) tim.hall (at) iint.com
http://www.indusworld.com

Replace domain name with the iint.com before replying via email! Received on Wed May 06 1998 - 11:16:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US