Received: from sysadmin.chi.wdr.com (sysadmin.chi.ubswarburg.com [146.180.1.66]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6HDPca43471 for ; Tue, 17 Jul 2001 09:25:38 -0400 (EDT) (envelope-from devin@sysadmin.chi.wdr.com) Received: from devin by sysadmin.chi.wdr.com with local (Exim 3.12 #2) id 15MUqq-0005Nm-00; Tue, 17 Jul 2001 08:25:24 -0500 Date: Tue, 17 Jul 2001 08:25:15 -0500 (CDT) From: Tod McQuillin X-X-Sender: To: Carlos cc: Subject: Re: Select distinct and order by. In-Reply-To: <3B4C1145.97056A0A@solaria-mediterranea.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200107/218 X-Sequence-Number: 4014 On Wed, 11 Jul 2001, Carlos wrote: > Select distinct field1, field2 from table1 order by field3; > > The value return by PQresultErrorMessage is: > > For SELECT DISTINCT, ORDER BY expressions must appear in target list That's because this query is ambiguous. What if table1 looks like this: field1 field2 field3 ------ ------ ------ a b 1 a b 3 c d 2 What should your query return then? Both a b c d and c d a b are valid, depending on which 'a b' row was chosen. If 6.5.3 allowed that, it was a mistake to rely on it because the answer is undefined. -- Tod McQuillin