Re: [HACKERS] Views on aggregates - need assistence

From: "Vadim B(dot) Mikheev" <vadim(at)sable(dot)krasnoyarsk(dot)su>
To: Brett McCormick <brett(at)work(dot)chicken(dot)org>
Cc: Jan Wieck <jwieck(at)debis(dot)com>, PostgreSQL HACKERS <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Views on aggregates - need assistence
Date: 1998-02-24 05:19:53
Message-ID: 34F25879.22AC935B@sable.krasnoyarsk.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Brett McCormick wrote:
>
> Thank you for addressing this issue! It has been bugging me for a
> while. Usually I just select into a new table and select from that
> (but yes, it is multiple queries). Normally I want to do something
> like:
>
> select bar,count(a.oid) as c from a,b where a.ab = b.bar and c > 1;
^^^^^
This is what HAVING is for (unimplemented, yet).

>
> This actually seems to be a different issue with more complicated
> unresolvable (?) problems, because you want a pre-result (per
> combination of instances matched) where and a result where (per result
> tuple).. Is this possible to do using subqueries? I'll try to find out.

No, if you really want to see count in output. If you would be happy
with bar only then this could help:

select bar from b where 1 < (select count(*) from a where a.ab = b.bar);

(Having HAVING would be better, of 'course :)

> This might be totally unrelated, actually. I do not know enough about
> view system to understand unresolvable conflicts.

You could CREATE VIEW V as select bar,count(a.oid) as c from a,b
where a.ab = b.bar group by bar;
and then just select * from v where c > 1.

Vadim

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom I Helbekkmo 1998-02-24 05:44:28 Re: [HACKERS] Current 6.3 issues
Previous Message Brett McCormick 1998-02-24 05:00:31 Re: [HACKERS] Here it is - view permissions