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 21:28:38 |
Message-ID: | 1139866118.1647.2.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, 2006-02-13 at 17:10 +0100, Mathieu Arnold wrote:
> | 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
>
> No, you don't understand, you should do something like :
>
> case when foo = bar then from else receiving_time desc end
>
Can't do so, because receiving_time is timestamptz, and "from" is
varchar. There:
pulitzer2=# select id, "from", receiving_time from messages order by
case when 2=3 then "from" else receiving_time end desc limit 5;
ERROR: CASE types timestamp with time zone and character varying cannot
be matched
I need to explicitly cast receiving_time into varchar.
What I would like to include ASC/DESC into CASE, but I guess that's not
possible.
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Fenbers | 2006-02-14 00:14:47 | group by complications |
Previous Message | Andreas Joseph Krogh | 2006-02-13 19:29:21 | Re: Problems with distinct |