Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 913FB9F946B for ; Wed, 15 Nov 2006 18:28:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 33194-01 for ; Wed, 15 Nov 2006 22:28:40 +0000 (UTC) X-Greylist: delayed 21:12:54.631574 by SQLgrey- Received: from clam.niwa.co.nz (clam.niwa.co.nz [202.36.29.1]) by postgresql.org (Postfix) with ESMTP id 3C78E9F935B for ; Wed, 15 Nov 2006 18:28:39 -0400 (AST) Received: from storm-imap.niwa.co.nz (storm-imap.niwa.co.nz [192.168.59.111]) by clam.niwa.co.nz (8.13.1/8.13.1) with ESMTP id kAFMSXBe092093; Thu, 16 Nov 2006 11:28:33 +1300 (NZDT) (envelope-from b.wood@niwa.co.nz) Received: from [192.168.57.107] (woodb-ws.greta.niwa.cri.nz [192.168.57.107]) by storm-imap.niwa.co.nz (8.12.10/8.12.10) with ESMTP id kAFMSWp4024904; Thu, 16 Nov 2006 11:28:33 +1300 (NZDT) (envelope-from b.wood@niwa.co.nz) Message-ID: <455B9490.6060004@niwa.co.nz> Date: Thu, 16 Nov 2006 11:28:32 +1300 From: Brent Wood Reply-To: b.wood@niwa.co.nz Organization: NIWA User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060411) X-Accept-Language: en-us, en MIME-Version: 1.0 CC: MicroUser , pgsql-general@postgresql.org Subject: Re: ORDER BY References: <1163541820.580520.110310@k70g2000cwa.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (clam.niwa.co.nz [192.168.16.8]); Thu, 16 Nov 2006 11:28:33 +1300 (NZDT) X-Scanned-By: MIMEDefang 2.56 on 192.168.16.8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/1140 X-Sequence-Number: 104236 > On 14 nov 2006, at 23.03, MicroUser wrote: >> I need sorted result but the way like this: >> >> 0 | Anna >> 3 | Fernando >> 2 | Link >> 1 | Other >> >> Record '1 | Other' must by at the end of query result. >> >> How I can get it? Something along these lines might work. select * from table where !=1 order desc by union select * from table where =1; or if the last record is always the same, hard code the values in the sql instead of querying the table, which will save a few milliseconds :-) If it is the "other" and not the "1" that you want last, change the first query where clause to where != 'Other' & similarly change the second one. Cheers, Brent Wood