From: | salah jubeh <s_jubeh(at)yahoo(dot)com> |
---|---|
To: | harald(at)2ndQuadrant(dot)com |
Cc: | pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: correlated query as a column and where clause |
Date: | 2011-04-15 15:49:20 |
Message-ID: | 809408.80124.qm@web161510.mail.bf1.yahoo.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Harald,
Danke ! . My concern is why I get error undefiend attribute if I used the alias
in the where clause
Regards
________________________________
From: Harald Armin Massa <harald(at)2ndQuadrant(dot)com>
To: salah jubeh <s_jubeh(at)yahoo(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Sent: Fri, April 15, 2011 5:26:45 PM
Subject: Re: [GENERAL] correlated query as a column and where clause
I am wondering, why I can not add the following ' A > 10' in the where
clause i.e. 'where nspname !~* 'pg_' and A > 10'
>
>Select nspname, (SELECT count(*) as count FROM pg_tables where schemaname =
>nspname) as A
>
>FROM pg_namespace
>where nspname !~* 'pg_'
>
>
>
what you are looking for is the having clause
Select nspname, count(1)
FROM pg_tables
where nspname !~* 'pg_'
group by nspname
having count(1) >10
best wishes
Harald
--
Harald Armin Massa www.2ndQuadrant.com
PostgreSQL Training, Services and Support
2ndQuadrant Deutschland GmbH
GF: Harald Armin Massa
Amtsgericht Stuttgart, HRB 736399
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-04-15 15:49:35 | Re: correlated query as a column and where clause |
Previous Message | salah jubeh | 2011-04-15 15:44:13 | Re: correlated query as a column and where clause |