Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 833944758FE for ; Thu, 21 Nov 2002 09:47:27 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 223B2475E2B for ; Thu, 21 Nov 2002 09:47:22 -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 gALElKsX011687; Thu, 21 Nov 2002 09:47:20 -0500 (EST) To: Jakub Ouhrabka Cc: "Rajesh Kumar Mallah." , pgsql-sql@postgresql.org Subject: Re: why the difference? In-reply-to: References: Comments: In-reply-to Jakub Ouhrabka message dated "Thu, 21 Nov 2002 09:42:33 +0100" Date: Thu, 21 Nov 2002 09:47:20 -0500 Message-ID: <11686.1037890040@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/329 X-Sequence-Number: 10471 Jakub Ouhrabka writes: > the where clause is evaluated before the distinct clause, so your queries > aren't equivalent because you switched the order by splitting the query > into two queries... Besides which, SELECT DISTINCT ON is order-sensitive. If you don't use an ORDER BY with it, you are going to get rather unpredictable results. See the example on the SELECT reference page. regards, tom lane