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: SQL Question

Re: SQL Question

From: Robert Liziniewicz <robertl_at_ci.comarch.pl>
Date: Wed, 10 Feb 1999 11:44:37 GMT
Message-ID: <36C16F1C.38E1A591@ci.comarch.pl>


try this:

select t1id,count(t2.id)

   from table1 t1,table2 t2
   where t1.id = t2.t1_id
   group by t1.id;

where:
t1.id - primary key of t1 table
t2.t1_id - foreign key in t2 table referencing t1.id primary

Regards
Robert

antonio wrote:

> Hi,
>
> I'm having some difficulties finding out the right SQL statement.
> This is the problem:
>
> I have two tables, let's say table1 and table2.
>
> table1 is the mastertable and table2 is the detail table.
>
> First I have to make a selection in the first table. Then i have to count
> the number of detailrecords.
> I want to display the selected masterrecords and the number of
> detailrecords.
>
> How can I do this?
>
> Antonio.

--

Robert Liziniewicz                    C.I. HTS-ComArch
Robert.Liziniewicz_at_ci.comarch.pl      ul. Ujastek 10, Krakow
                                      tel. (+48 12) 644-66-31
                                           (+48 601) 47-86-81


Received on Wed Feb 10 1999 - 05:44:37 CST

Original text of this message

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