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: Frank Thomas <thomasf_at_daugherty.com>
Date: 1997/01/16
Message-ID: <5bl9mq$pcg@speedy.daugherty.com>#1/1

Greg Hopkins <gregho_at_mosaix.com> 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

How about this:

select c1 from t
group by c1
having count(*) = 2

>Thanks !!!
 

>Please respond to: gregho_at_mosaix.com

Frank Thomas
thomasf_at_daugherty.com Received on Thu Jan 16 1997 - 00:00:00 CST

Original text of this message

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