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 -> Re: how to ?? sql query

Re: how to ?? sql query

From: Claude-Sebastien Jean <csjean_at_logimens.com>
Date: 1997/01/15
Message-ID: <32DD5B65.3EA4@logimens.com>#1/1

Greg Hopkins wrote:
>
> How can I code SQL to do this ??
>
> The table looks like:
>
> Table T
> col C1 col C2
> --------------------
> 101 201
> 102 201
> 102 202
> 103 201
> 103 202
> 103 203
>
> ie, in col C1 there is an ID number, and col C2 is a tag for the ID num.
>
> I want to do something like:
>
> SELECT C1 FROM T WHERE COUNT(C1) = 2
>
> which would return 102 because ID 102 appears twice in column C1.
>
> SELECT C1 FROM T WHERE COUNT(C1) = 3 would return 103 etc.
>
> I started looking at GROUP BY, HAVING etc
>
> Thanks !!!
>
> Please respond to: gregho_at_mosaix.com

Hi!

The SQL code would be

SELECT C1 FROM T
GROUP BY C1
HAVING COUNT(C1) = 2; ...and voilĂ 

I hope this helps.

-- 
CSJ
csjean_at_logimens.com
Received on Wed Jan 15 1997 - 00:00:00 CST

Original text of this message

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