Re: SQLServer to Oracle

From: Anupriyo Chakravarti <anu_chak_at_globalnoise.com>
Date: 20 Aug 2001 11:42:50 -0700
Message-ID: <c0fcc770.0108201042.73d31378_at_posting.google.com>


Well, this leaves out all parents that have no children.

avdbi_at_hotmail.com (Anurag Varma) wrote in message news:<7171ca2d.0108160031.764ca513_at_posting.google.com>...
> Not tested this but:
> assuming: names are same for identical id's
> SELECT p.id, p.name, count(*)
> FROM TPARENT p,TCHILD c
> WHERE p.id = c.id
> GROUP BY p.id,p.name
>
>
>
> anu_chak_at_globalnoise.com (Anupriyo Chakravarti) wrote in message news:<c0fcc770.0108151112.20329432_at_posting.google.com>...
> > This query works in MS SQL Server but not in Oracle 8. Any suggestions
> > how to achieve the samething in Oracle?
> >
> > SELECT TPARENT.id, TPARENT.name
> > (SELECT COUNT(*) FROM TPARENT, TCHILD WHERE TCHILD.parentid =
> > TPARENT.id) AS numchildren
> > FROM TPARENT
> >
> > Basically, I have two tables TPARENT and TCHILD. TCHILD has a FK
> > parentid to TPARENT.id. I want a list of all parents and the number of
> > children they have.
> >
> > Any insights would be appreciated.
> >
> > - Anupriyo
Received on Mon Aug 20 2001 - 20:42:50 CEST

Original text of this message