Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E3A78B5DC07 for ; Fri, 28 Oct 2011 02:07:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 80429-01 for ; Fri, 28 Oct 2011 05:07:18 +0000 (UTC) X-Greylist: delayed 00:13:30.344889 by SQLgrey-1.8.0-rc2 Received: from smtp-out-emea.greenpeace.org (smtp-out-emea.greenpeace.org [85.234.235.81]) by mail.postgresql.org (Postfix) with ESMTP id 7A479B5DC23 for ; Fri, 28 Oct 2011 02:07:18 -0300 (ADT) Received: from mta-ams.nli.gl3 ([10.31.1.2]) by smtp-out-emea.greenpeace.org (8.13.8/8.13.8) with ESMTP id p9S4rdsm010866 for ; Fri, 28 Oct 2011 06:53:39 +0200 Received: from mta-ams.nli.gl3 (localhost.localdomain [127.0.0.1]) by mta-ams.nli.gl3 (Postfix) with ESMTP id A0E131001CE for ; Fri, 28 Oct 2011 06:50:06 +0200 (CEST) Received: from mail.isu.gl3 (base.isu.gl3 [192.168.210.1]) by mta-ams.nli.gl3 (Postfix) with ESMTP id 9D8381000FC for ; Fri, 28 Oct 2011 06:50:06 +0200 (CEST) Received: from [10.10.10.10] (unknown [192.168.206.202]) by mail.isu.gl3 (Postfix) with ESMTP id 751803F86 for ; Fri, 28 Oct 2011 04:53:38 +0000 (UTC) Message-ID: <4EAA3550.7080609@greenpeace.org> Date: Fri, 28 Oct 2011 17:53:36 +1300 From: Jan Bakuwel Organization: Greenpeace (http://www.greenpeace.org) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Different order by behaviour depending on where clause? X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-GP-MailScanner-Information: Please contact local support for more information X-GP-MailScanner-ID: p9S4rdsm010866 X-GP-MailScanner: Found to be clean X-GP-MailScanner-From: jan.bakuwel@greenpeace.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/83 X-Sequence-Number: 35967 Hi, I have a compound query with some grouping, having and order by's saved as a view, say with name "myview". A) select * from "myview" returns the results as expected in the correct order (the order by is on fields "Category", "Year", "Month" and a few other fields). The results are correctly ordered by these fields as specified in the view. B) select * from "myview" where "Year"=2011 and "Month"=1 also returns the results as expected in the correct order (a subset of A). however C) select * from "myview" where "Year"=2011 and "Month" >= 1 and "Month" <= 1 returns the same resultset as B but the order of the rows is not correct (not even close; haven't been able to see any pattern). Any idea how I can further analyse/diagnose this? regards, Jan