Re: CASE in ORDER BY clause - Mailing list pgsql-general

From Louis-David Mitterrand
Subject Re: CASE in ORDER BY clause
Date
Msg-id 20070707083712.GA8488@apartia.fr
Whole thread Raw
In response to Re: CASE in ORDER BY clause  (Viatcheslav Kalinin <vka@ipcb.net>)
Responses Re: CASE in ORDER BY clause
List pgsql-general
On Fri, Jul 06, 2007 at 08:02:54PM +0400, Viatcheslav Kalinin wrote:
>
> # select start_date from show_date
> # order by
> # case when start_date > CURRENT_DATE then start_date end desc,
> # case when start_date <= CURRENT_DATE then start_date end asc;

The strange thing is when I try:

    select start_date from show_date order by case when start_date > CURRENT_DATE then 'start_date asc' else
'start_datedesc ' end; 

It lists start_date's without ordering them (does nothing).

However if I try:

    select start_date from show_date order by 'start_date desc';

I get a:

    ERROR:  non-integer constant in ORDER BY

Bug? Inconsistency?

pgsql-general by date:

Previous
From: Louis-David Mitterrand
Date:
Subject: Re: CASE in ORDER BY clause
Next
From: "Leon Mergen"
Date:
Subject: Unable to get postgres running after long time no vacuum