pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
To: pgsql-sql@postgresql.org
Subject: Re: ORDER BY CASE ...
Date: Mon, 13 Feb 2006 16:40:24 +0100
Message-ID: <20060213154024.GJ46853@spoetnik.xs4all.nl> (raw)
In-Reply-To: <1139844930.13054.23.camel@localhost.localdomain>
References: <1139844930.13054.23.camel@localhost.localdomain>

On Mon, Feb 13, 2006 at 04:35:30PM +0100, Mario Splivalo wrote:
> Am I misusing the ORDER BY with CASE, or, what? :)
> 
> I have a table, messages, half dozen of columns, exposing here just
> three of them:
> 
> pulitzer2=# select id, "from", receiving_time from messages where
> service_id = 20 order by case when 5=5 then 2 else 3 end desc limit 5;

I'm not sure what you are trying to do here, but it seems that an order by 
statement should at least contain something that is part of the resultrow. 
"case when 5=5 then 2 else 3 end desc limit 5" does not contain any column 
to sort on. So I think it will evaluate to some constant value and not 
sorting is really done 

-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud.v@n.leeuwen.net
http://www.xs4all.nl/~reinoud
__________________________________________________



view thread (7+ messages)  latest in thread

Message-ID: <20060213154024.GJ46853@spoetnik.xs4all.nl>
Permalink:  ../20060213154024.GJ46853@spoetnik.xs4all.nl/
Also on:    postgresql.org/message-id/20060213154024.GJ46853@spoetnik.xs4all.nl

 · 

reply

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: reinoud.v@n.leeuwen.net
  Subject: Re: ORDER BY CASE ...
  In-Reply-To: <20060213154024.GJ46853@spoetnik.xs4all.nl>

* 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