From: Mario Splivalo <mario.splivalo@mobart.hr>
To: Mathieu Arnold <mat@mat.cc>
Cc: pgsql-sql@postgresql.org
Subject: Re: ORDER BY CASE ...
Date: Mon, 13 Feb 2006 16:47:48 +0100
Message-ID: <1139845669.13054.28.camel@localhost.localdomain> (raw)
In-Reply-To: <9693350566E722C466358E08@[192.168.9.47]>
References: <1139844930.13054.23.camel@localhost.localdomain>
<9693350566E722C466358E08@[192.168.9.47]>
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."
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mario.splivalo@mobart.hr, mat@mat.cc
Subject: Re: ORDER BY CASE ...
In-Reply-To: <1139845669.13054.28.camel@localhost.localdomain>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox