Re: correlated query as a column and where clause - Mailing list pgsql-general

From Harald Armin Massa
Subject Re: correlated query as a column and where clause
Date
Msg-id BANLkTimTnxqD=Br8wpzjJ1RdKQT7ksX4AQ@mail.gmail.com
Whole thread Raw
In response to correlated query as a column and where clause  (salah jubeh <s_jubeh@yahoo.com>)
Responses Re: correlated query as a column and where clause
List pgsql-general
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

pgsql-general by date:

Previous
From: salah jubeh
Date:
Subject: correlated query as a column and where clause
Next
From: Chris Curvey
Date:
Subject: Re: correlated query as a column and where clause