From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Russell Simpkins <russellsimpkins@hotmail.com>
Cc: mike@fuhr.org
Cc: pgsql-sql@postgresql.org
Subject: Re: ORDER records based on parameters in IN clause
Date: Wed, 29 Jun 2005 10:07:18 -0500
Message-ID: <1120057638.8208.117.camel@state.g2switchworks.com> (raw)
In-Reply-To: <BAY103-F2C56F6C371B9B2FDEEDCBB5E00@phx.gbl>
References: <BAY103-F2C56F6C371B9B2FDEEDCBB5E00@phx.gbl>
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;
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: smarlowe@g2switchworks.com, russellsimpkins@hotmail.com, mike@fuhr.org
Subject: Re: ORDER records based on parameters in IN clause
In-Reply-To: <1120057638.8208.117.camel@state.g2switchworks.com>
* 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