I want to return all results from a table that meet this conditional:
COLUMN-A has 5 rows.
But, for these results, COLUMN-B must also be a distinct value.
So for instance, in the following example, I want to get back a value of "1", because column-A has 5 rows and column-B has the same distinct value. Column-A is ignored for "2", because there aren't the same value for Column-B.
TABLE
-----
COLUMN-A COLUMN-B
-------- --------
1 8
1 8
1 8
1 8
1 8
2 9
2 9
2 9
2 7
2 7
I thought the key would be to write a query like this:
select * from table
where column-A in(select column-A from table group by column-A having count(column-A) > 5
and
column-B in(select column-B from table group by column-B having count(column-B) > 5)
)
But this doesn't work.
Probably something goofy I'm missing.
I'd appreciate a hand.
thanks!
2007-02-14
07:54:39
·
5 answers
·
asked by
Rob
5
in
Computers & Internet
➔ Programming & Design
I meant to write >= 5 in the query. That's how it should read.
2007-02-14
07:57:22 ·
update #1