Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to find tuples with same attr. value
>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
![]() |
![]() |