Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 414CBB5DC1C for ; Sat, 29 Oct 2011 18:17:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 68467-01 for ; Sat, 29 Oct 2011 21:17:09 +0000 (UTC) X-Greylist: from auto-whitelisted 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 B62F2B5D91F for ; Sat, 29 Oct 2011 18:17:08 -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 p9TLGxl0020627; Sat, 29 Oct 2011 23:16:59 +0200 Received: from mta-ams.nli.gl3 (localhost.localdomain [127.0.0.1]) by mta-ams.nli.gl3 (Postfix) with ESMTP id C4066100132; Sat, 29 Oct 2011 23:13:25 +0200 (CEST) Received: from mail.isu.gl3 (base.isu.gl3 [192.168.210.1]) by mta-ams.nli.gl3 (Postfix) with ESMTP id C181D1000F6; Sat, 29 Oct 2011 23:13:25 +0200 (CEST) Received: from [10.10.10.10] (unknown [192.168.206.202]) by mail.isu.gl3 (Postfix) with ESMTP id 5237B1F60; Sat, 29 Oct 2011 21:16:56 +0000 (UTC) Message-ID: <4EAC6D46.1060602@greenpeace.org> Date: Sun, 30 Oct 2011 10:16:54 +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: Phil Couling CC: Pavel Stehule , pgsql-sql@postgresql.org Subject: Re: Different order by behaviour depending on where clause? References: <4EAA3550.7080609@greenpeace.org> In-Reply-To: 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: p9TLGxl0020627 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/89 X-Sequence-Number: 35973 Hi Phil, Thanks for your reply. On 28/10/11 23:25, Phil Couling wrote: > Hi Jan > > It is my understanding that a select query without "order by" has an > undefined order. > Though I'm sure you understand the dangers of using something which is > undefined, I'm going reiterate them here: I think you might have misread my email, I'm quoting: "I have a compound query with some grouping, having and order by's saved as a view, say with name "myview". So... I am using explicit order by's. The problem (now solved) was that I somewhere subtle "hidden" in one of my subqueries, type casted a row (varchar to int) but omitted to do the same one or two "levels up". This messed up my sorting. Once I applied the type cast in every single bit of statement or all (sub)selects, all was OK. kind regards, Jan