Re: [SQL] Select & Tables X Select & Views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rodrigo Rezende <Rodrigo(dot)Rezende(at)hortolandia(dot)marelli(dot)it>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Select & Tables X Select & Views
Date: 2000-02-21 22:27:08
Message-ID: 29583.951172028@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Rodrigo Rezende <Rodrigo(dot)Rezende(at)hortolandia(dot)marelli(dot)it> writes:
> The view :
> create view func_aux_stat as select fp.codfuncionario, max(fp.data) as
> data from func_preench as fp group by fp.codfuncionario ;

Ah. I'm afraid GROUP BY doesn't work very well in views --- it's OK
for simply selecting from the grouped view, but not for joining it
against other tables. This is because the rule rewriter can only
revise your query into some other query that's still expressible in
SQL, and there's no way to group only one table in a query in the
subset of SQL that we support.

We hope to fix this in 7.1, but for now it's not going to work.
You might think about trying to recast your problem to use subselects,
or some other approach that doesn't involve joining a grouped table
against an ungrouped one.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2000-02-21 23:57:53 Re: [SQL] rule plan string too big
Previous Message Rodrigo Rezende 2000-02-21 15:38:16 rule plan string too big