X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC3DD474E44 for ; Thu, 3 Apr 2003 19:42:18 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 51851474E42 for ; Thu, 3 Apr 2003 19:42:18 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2941352; Thu, 03 Apr 2003 16:42:13 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "James Taylor" , Subject: Re: More wacky grouping Date: Thu, 3 Apr 2003 16:42:16 -0800 User-Agent: KMail/1.4.3 References: <002601c2fa41$3a88d760$4500a8c0@theplague> In-Reply-To: <002601c2fa41$3a88d760$4500a8c0@theplague> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304031642.16094.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/58 X-Sequence-Number: 12759 James, > I need to do grouping based on various aggregates, but the way my table > is set up (it can't change) is making things kind of difficult. Yeah. You should track down the previous database designer and break his= =20 fingers .... Anyway, you'll need to work through subselects. That is, subselect each= =20 datatype from the table as if it were a seperate table and join them, e.g. FROM (SELECT content, id_customer FROM table1 WHERE id_datatype =3D 2) tb2, (SELECT content, id_customer FROM table1 WHERE id_datatype =3D 3) tb3 etc. Also, since you'll be summing on a text field which is being converted to= =20 NUMERIC on the fly, expect your query to be slow as molasses. --=20 -Josh Berkus Aglio Database Solutions San Francisco