pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: M.D.G. Lange <mlange@dltmedia.nl>
To: pgsql-sql@postgresql.org
Subject: Re: ORDER records based on parameters in IN clause
Date: Thu, 30 Jun 2005 09:34:59 +0200
Message-ID: <42C3A0A3.40101@dltmedia.nl> (raw)
In-Reply-To: <1120057638.8208.117.camel@state.g2switchworks.com>
References: <BAY103-F2C56F6C371B9B2FDEEDCBB5E00@phx.gbl>
	<1120057638.8208.117.camel@state.g2switchworks.com>

Another option would be:

SELECT * FROM table WHERE id=2003 OR id=1342 OR id=799 OR id=1450;

This should give you the results in the right order...

- Michiel

Scott Marlowe wrote:

>On Wed, 2005-06-29 at 09:22, Russell Simpkins wrote:
>  
>
>>fair enough. but a simple order by id would never work.
>>
>>    
>>
>
>Try this:
>
>select 	*,
>	case 
>		when id=2003 then 1 
>		when id=1342 then 2 
>		when id=799 then 3 
>		when id=1450 then 4 
>	end as ob 
>from 
>	tablename 
>where 
>	id in (2003,1342,799,1450) 
>order by 
>	ob;
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
>
>
>  
>



view thread (16+ messages)  latest in thread

Message-ID: <42C3A0A3.40101@dltmedia.nl>
Permalink:  ../42C3A0A3.40101@dltmedia.nl/
Also on:    postgresql.org/message-id/42C3A0A3.40101@dltmedia.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: mlange@dltmedia.nl
  Subject: Re: ORDER records based on parameters in IN clause
  In-Reply-To: <42C3A0A3.40101@dltmedia.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