Received: from femail1.sdc1.sfba.home.com (femail1.sdc1.sfba.home.com [24.0.95.81]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0O7oE073900 for ; Wed, 24 Jan 2001 02:50:14 -0500 (EST) (envelope-from kumar1@home.com) Received: from c654771a ([24.176.200.175]) by femail1.sdc1.sfba.home.com (InterMail vM.4.01.03.00 201-229-121) with SMTP id <20010124074940.HFWY2567.femail1.sdc1.sfba.home.com@c654771a> for ; Tue, 23 Jan 2001 23:49:40 -0800 Message-ID: <003b01c085da$82aaa4c0$afc8b018@c654771a> From: "Prasanth Kumar" To: References: <3A6CD7E4.8BE6DDC3@pacbell.net> Subject: Re: Order By Question Date: Tue, 23 Jan 2001 23:51:50 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200101/313 X-Sequence-Number: 985 > This seems like the answer must be pretty easy, but I can't think of it: > > In the following statement: > > select field1 from my_table where field2 in (3, 1, 2); > > How can I modify this statement so that the record are returned in the > order of first those records having field2 = 3, then field2 = 1, then > field2 = 2. > As it stands, I am getting them returned in the order of the value of > field1. > One way is to have a priority table where each value is mapped to its associated priority and then you do a join against this table and order by the priority value instead. So you might have a table like follows: priority value 1 3 2 1 3 2 -- Prasanth Kumar kumar1@home.com