X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4C399D1E176 for ; Tue, 23 Mar 2004 05:17:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 52810-08 for ; Tue, 23 Mar 2004 01:17:25 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C089CD1CCDA for ; Tue, 23 Mar 2004 01:17:24 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2N5HOFY015733; Tue, 23 Mar 2004 00:17:24 -0500 (EST) To: "David Witham" Cc: pgsql-sql@postgresql.org Subject: Re: Sorting an aggregated column In-reply-to: References: Comments: In-reply-to "David Witham" message dated "Tue, 23 Mar 2004 14:26:15 +1100" Date: Tue, 23 Mar 2004 00:17:24 -0500 Message-ID: <15732.1080019044@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/228 X-Sequence-Number: 17327 "David Witham" writes: > This output is correct in this case but there is no guarantee that the > answers will come out in "question" order. I can't see how to > incorporate sorting by the "question" column using this approach. As of PG 7.4 you can reliably use a sorted sub-select to determine the order of inputs to a user-defined aggregate function. See for instance http://archives.postgresql.org/pgsql-general/2003-02/msg00917.php regards, tom lane