Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 64E4C9FB91A for ; Thu, 15 Feb 2007 09:35:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 87606-06 for ; Thu, 15 Feb 2007 09:35:20 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id EA42A9FB899 for ; Thu, 15 Feb 2007 09:35:19 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id A42D773E38; Thu, 15 Feb 2007 13:35:18 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 70EE4274164; Thu, 15 Feb 2007 13:35:18 +0000 (GMT) Message-ID: <45D46196.2090003@archonet.com> Date: Thu, 15 Feb 2007 13:35:18 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Walter Cruz Cc: pgsql-sql@postgresql.org Subject: Re: "for SELECT DISTINCT, ORDER BY expressions must appear in select list" - is that the standart or a limitation of postgresql? References: <32cabba0702150319v427d5a25s9a6c7f851576baa2@mail.gmail.com> In-Reply-To: <32cabba0702150319v427d5a25s9a6c7f851576baa2@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.214 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/163 X-Sequence-Number: 27497 Walter Cruz wrote: > > SELECT distinct name from test order by number > > (well, I think that que query doesn't make any sense, but raises the > error :) ) > > The error: ERROR: for SELECT DISTINCT, ORDER BY expressions must > appear in select list is due to a standart implementarion or a design > decision of postgres? I think ORDER BY is defined to take place after DISTINCT, which means there is no meaningful "number" for it to order by. You could arbitrarily choose the first number encountered, but I can't see what sense it would make to order by them. -- Richard Huxton Archonet Ltd