Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA97491 for ; Mon, 21 Feb 2000 17:27:44 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id RAA29586; Mon, 21 Feb 2000 17:27:09 -0500 (EST) To: Rodrigo Rezende cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Select & Tables X Select & Views In-reply-to: <38B132D3.5CEB990A@hortolandia.marelli.it> References: <20000218122631.C12742@rice.edu> <38B132D3.5CEB990A@hortolandia.marelli.it> Comments: In-reply-to Rodrigo Rezende message dated "Mon, 21 Feb 2000 09:42:59 -0300" Date: Mon, 21 Feb 2000 17:27:08 -0500 Message-ID: <29583.951172028@sss.pgh.pa.us> From: Tom Lane Rodrigo Rezende 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