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


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to