pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@kick.com>
To: Bernie Huang <bernie.huang@ec.gc.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Order by in Select
Date: Wed, 19 Jul 2000 17:38:23 -0700
Message-ID: <010b01bff1e2$cfe02760$0c64010a@kick.com> (raw)
References: <39764717.7B5EB600@ec.gc.ca>

> What can I add to the above sql statement so that is fetches the
> specified id first in a sorted list?
> 
> eg: if $specified_id=5;
> I want: 5,5,5,1,2,3,3,4,4,4,6,6,7
> 
> I could have done it in two different sql statements where one fetches
> specified_id and the other fetches and sorts others, but I want to be
> able to do it in one sql statement to reduce time.

Umm, maybe something like:
select id from table order by 
case when id=$specified_id then <minimal value for type> else id end





view thread (2+ messages)

Message-ID: <010b01bff1e2$cfe02760$0c64010a@kick.com>
Permalink:  ../010b01bff1e2$cfe02760$0c64010a@kick.com/
Also on:    postgresql.org/message-id/010b01bff1e2$cfe02760$0c64010a@kick.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: sszabo@kick.com, bernie.huang@ec.gc.ca
  Subject: Re: Order by in Select
  In-Reply-To: <010b01bff1e2$cfe02760$0c64010a@kick.com>
  References: <39764717.7B5EB600@ec.gc.ca> <010b01bff1e2$cfe02760$0c64010a@kick.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