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 find tuples with same attr. value

Re: How to find tuples with same attr. value

From: TommCarr <tommcarr_at_aol.com>
Date: 1997/07/09
Message-ID: <19970709200401.QAA18352@ladder02.news.aol.com>#1/1

>If i hava a table like:
>
>P ,T
>-----
>1 1
>2 2
>3 2
>4 3
>5 4
>6 4
>7 4
>8 5
>etc. (P is unique, T is not)
>
>how do i find those tuples where T-value appears 1, 2, 3 and 4 times?
>
>

There are probably easier ways but I did it like this:

create view test_view as
select t, count(t) count_t
from test
group by t;

Then I could play all sorts of games:

select * from test_view order by count_t;
select * from test_view where count_t = 3;
select * from test_view where count_t between 2 and 4;
select P from test where t in (select t from test_view where count_t = 3);

You get the idea.

Tomm Carr
In giving freedom to the slave we assure freedom to the free, honorable alike in what we give and what we preserve. ---- Abraham ByGod Lincoln Received on Wed Jul 09 1997 - 00:00:00 CDT

Original text of this message

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