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: rob <rob_at_dsdelft.nl>
Date: Wed, 6 May 1998 17:45:17 +0200
Message-ID: <6iq0o6$ogg$1@news.worldonline.nl>


>I'm trying to figure out how to select the number
>of children each parent has.
>
>For example, say Table1 (Parent) has a 1-to-many
>relationship with Table2 (Children); that is, Table1
>can have many Table2 records.
>
>For each record in Table1, I want to know the number
>of times it appears in Table2 as a Parent, i.e. For each
>Parent (in Table1), how many Children (records in Table2)
>does it have?
>

select parent_name, count(*)
from parent
, children
where parent.parent_id = child.parent_id group by parent_id;

Assuming all parents have children ;-)

Cheers Rob Received on Wed May 06 1998 - 10:45:17 CDT

Original text of this message

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