Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> SQL question
Hello,
I have 2 tables, the 1st one PERSON containing people descriptions and a 2nd RELATION containing data about relationships between PERSONs (child, spouse,...). I want to write a SQL statement to retrieve the number of children and spouses for each person in PERSON. Here's what I have so far:
select p.no, count(r.pers_no), count(r2.pers_no)
from person p, relation r, relation r2
where r.pers_no=p.no and r2.pers_no=p.no and r.cat = 'CHILD' and r2.cat =
'SPOUSE'
group by p.no
This is not working as I would like, so I need a little help.
Thank you all.
MR Received on Mon Sep 17 2001 - 14:55:24 CDT
![]() |
![]() |