Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Selecting number of "many" in 1-to-many
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
![]() |
![]() |