X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41B23474E5C for ; Sat, 1 Mar 2003 12:15:58 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 20349-07 for ; Sat, 1 Mar 2003 12:15:57 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 47A05474E42 for ; Sat, 1 Mar 2003 12:15:57 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h21HDW5u012196; Sat, 1 Mar 2003 12:13:32 -0500 (EST) To: Edmund Lian Cc: pgsql-sql@postgresql.org Subject: Re: Denormalizing during select In-reply-to: References: <200302241433.49502.josh@agliodbs.com> Comments: In-reply-to Edmund Lian message dated "Tue, 25 Feb 2003 18:48:19 +0000" Date: Sat, 01 Mar 2003 12:13:32 -0500 Message-ID: <12195.1046538812@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/14 X-Sequence-Number: 12054 Edmund Lian writes: > Answering my own question: kind of. The problem with custom aggregates > is that they need to be used with a "group by" clause, and this means > that the select cannot return columns that are not aggregates of some > kind. What I'm trying to return are rows that are a combination of > columns and aggregates. This strikes me as evidence of fuzzy thinking. What sets of rows are the aggregates taken over? Which column values within those sets of rows do you expect the non-aggregated column references to return? If the columns aren't the ones grouped by, seems like you have an inherently undefined result. If you know for some reason that there will be only one unique value of a column in a grouped row set, or you don't actually much care which one you get, then you could use MIN() or MAX() on the column reference to make it look like a kosher query. regards, tom lane