Received: from sandtstudent.pyr.ec.gc.ca (fwvan1.pyr.ec.gc.ca [199.212.20.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e6K0QKh86811 for ; Wed, 19 Jul 2000 20:26:20 -0400 (EDT) Received: from ec.gc.ca (IDENT:huangb@sandtstudent [131.235.150.249]) by sandtstudent.pyr.ec.gc.ca (8.9.3/8.9.3) with ESMTP id RAA13437 for ; Wed, 19 Jul 2000 17:26:04 -0700 Message-ID: <39764717.7B5EB600@ec.gc.ca> Date: Wed, 19 Jul 2000 17:25:59 -0700 From: Bernie Huang Organization: Environment Canada X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: PGSQL-SQL Subject: Order by in Select Content-Type: multipart/mixed; boundary="------------35514919520598CC08C0BC69" X-Archive-Number: 200007/185 This is a multi-part message in MIME format. --------------35514919520598CC08C0BC69 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Hello, I have a list of id's that I need to sort and fetch. eg; 1,3,6,5,4,3,4,5,6,7,5,4,2 Select id From table Order By id Asc; it becomes like: 1,2,3,3,4,4,4,5,5,5,6,6,7 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. Any ideas? Thank you! - Bernie --------------35514919520598CC08C0BC69 Content-Type: text/x-vcard; charset=iso-8859-15; name="bernie.huang.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Bernie Huang Content-Disposition: attachment; filename="bernie.huang.vcf" begin:vcard n:Huang;Bernie tel;fax:(604)664-9195 tel;work:(604)664-9172 x-mozilla-html:TRUE org:Environment Canada;Standards and Technology Services adr:;;700-1200 West 73 Ave.;Vancouver;BC;V6P 6H9;Canada version:2.1 email;internet:bernie.huang@ec.gc.ca title:Programmer x-mozilla-cpt:;0 fn:Bernie Huang end:vcard --------------35514919520598CC08C0BC69--