Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> query to find references

query to find references

From: Michiel Perdeck <perdeck.via_at_sni.de>
Date: 1997/05/28
Message-ID: <338BD681.58B@sni.de>#1/1

Hi you SQL guru's out there, please help me with the following query:

I have a table A and a table B. Rows in B contain a foreign key to A. I want to find all instances of A to which less than a certain number, say N, rows in B refer. A naive query would look like this but is not accepted by Oracle7 ('a' is the name of the key field):

SELECT * FROM A
WHERE (SELECT COUNT(*) FROM B
       WHERE B.a = A.a) < N

Why doesn't this simple query work?
How should I get what I want?

Thanks for any help,
Michiel

-- 
Michiel Perdeck

------------------------------------------------------------------------
Siemens Nixdorf: perdeck.via_at_sni.de +31 70 3331530 fax: 3331320 CMG AT Finance : michiel.perdeck_at_cmg.nl +31 20 5033000 fax: 5033011 private : michiel.perdeck_at_tip.nl +31 30 6570818 pager: 0659676940
------------------------------------------------------------------------
Received on Wed May 28 1997 - 00:00:00 CDT

Original text of this message

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