Re: SQL CORR SUBQUERY EXPERTS

From: Naren Chintala <naren_at_mink.att.com>
Date: 1996/07/26
Message-ID: <4tb4d0$c29_at_newsa.netnews.att.com>#1/1


mgreen1962_at_aol.com (MGreen1962) wrote:
>Hello, 2 all that would try to answer this question.
>
>How would I write a query that returns group rows where the count >= some
>value.
>
>i.e.
> select table_name,count(*)
> from sys.dba_constraints
> where count(*) >= 7
> group by table_name;
>
>I know the count(*) function cannot be used in a where clause. I tried to
>use a correlated subquery and my system locked each time. My query is as
>follows:
>
>select table_name,count(*) from sys.dba_constraints x
> where to_number('1')>=(select count(*) from sys.dba_constraints where
> x.table_name=table_name)
> group by table_name;
>
>Please help. email Mgreen1962_at_aol.com

Try this

select table_name, count(*) from sys.dba_constraints group by table_name having count(*) > 7;

Naren Chintala
naren_at_mink.att.com Received on Fri Jul 26 1996 - 00:00:00 CEST

Original text of this message