X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2371C9DCC0C for ; Mon, 13 Feb 2006 11:47:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44681-07 for ; Mon, 13 Feb 2006 11:47:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id C14B49DCC11 for ; Mon, 13 Feb 2006 11:47:44 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id AD3DF17A8B; Mon, 13 Feb 2006 16:47:49 +0100 (CET) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 02172-03-4; Mon, 13 Feb 2006 16:47:49 +0100 (CET) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id 90BB317A89; Mon, 13 Feb 2006 16:47:49 +0100 (CET) Subject: Re: ORDER BY CASE ... From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: Mathieu Arnold Cc: pgsql-sql@postgresql.org In-Reply-To: <9693350566E722C466358E08@[192.168.9.47]> References: <1139844930.13054.23.camel@localhost.localdomain> <9693350566E722C466358E08@[192.168.9.47]> Content-Type: text/plain Organization: Mob-Art Date: Mon, 13 Feb 2006 16:47:48 +0100 Message-Id: <1139845669.13054.28.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.151 required=5 tests=[AWL=0.151] X-Spam-Score: 0.151 X-Spam-Level: X-Archive-Number: 200602/133 X-Sequence-Number: 24143 On Mon, 2006-02-13 at 16:39 +0100, Mathieu Arnold wrote: > | > | > | I tought I'd get differently sorted data, since in the first query I > | said 5=5, and in second I said 5=6. > > Well, no, in the first, the result of the CASE is 2, and in the second 3, it > means that for every line, it'll sort using "2" as value for the first, and > "3" for the second query. > Yes, I realized just a second ago that when ORDER BY is CASED, numbers aren't the column numbers, but the integers itself. It works like this: ORDER BY (CASE WHEN 5=5 THEN "from"::varchar ELSE receiving_time::varchar) DESC. Is there a way to have DESC/ASC inside of a CASE? Mario -- Mario Splivalo Mob-Art mario.splivalo@mobart.hr "I can do it quick, I can do it cheap, I can do it well. Pick any two."