Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question
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-81Received on Wed Feb 10 1999 - 05:44:37 CST