From: | Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> |
---|---|
To: | Mathieu Arnold <mat(at)mat(dot)cc> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: ORDER BY CASE ... |
Date: | 2006-02-13 15:47:48 |
Message-ID: | 1139845669.13054.28.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(dot)splivalo(at)mobart(dot)hr
"I can do it quick, I can do it cheap, I can do it well. Pick any two."
From | Date | Subject | |
---|---|---|---|
Next Message | Mathieu Arnold | 2006-02-13 16:10:48 | Re: ORDER BY CASE ... |
Previous Message | Reinoud van Leeuwen | 2006-02-13 15:40:24 | Re: ORDER BY CASE ... |