Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 315FA6327E1 for ; Thu, 30 Jul 2009 17:05:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 93678-04 for ; Thu, 30 Jul 2009 20:05:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vs137086.vserver.de (static-ip-62-75-137-86.inaddr.intergenia.de [62.75.137.86]) by mail.postgresql.org (Postfix) with ESMTP id 573A9634D84 for ; Thu, 30 Jul 2009 17:05:32 -0300 (ADT) Received: (qmail 18324 invoked from network); 30 Jul 2009 22:05:30 +0200 Received: from p54b3b3d0.dip0.t-ipconnect.de (HELO a-kretschmer.de) (84.179.179.208) by static-ip-62-75-137-86.inaddr.intergenia.de with (AES256-SHA encrypted) SMTP; 30 Jul 2009 22:05:30 +0200 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1MWbsX-0003Jg-AI for pgsql-sql@postgresql.org; Thu, 30 Jul 2009 22:05:29 +0200 Date: Thu, 30 Jul 2009 22:05:29 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: Show CAS, USD first; the left ordered by currency name Message-ID: <20090730200529.GA12697@tux> References: <4A71F9CB.9050805@encs.concordia.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4A71F9CB.9050805@encs.concordia.ca> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/157 X-Sequence-Number: 32898 Emi Lu wrote: > Good morning, > > I have a currency table (code, description). > > Example values: > ADF | Andorran Franc > ... ... > ANG | NL Antillian Guilder > AON | Angolan New Kwanza > AUD | Australian Dollar > AWG | Aruban Florin > BBD | Barbados Dollar > USD | US Dollar > CAD | Canadian Dollar > > Is there a way I can query to display USD AND CAD first, while other > rows are ordered by Code. > > For example, > > CAS | Canadian Dollar > USD | US Dollar > ADF | Andorran Franc > ... > Sure: test=*# select * from currency order by case when code='USD' then 0 when code = 'CAD' then 1 end, code; code | description ------+---------------------- USD | US Dollar CAD | Canadian Dollar ADF | Andorran Franc ANG | NL Antillian Guilder AON | Angolan New Kwanza AUD | Australian Dollar AWG | Aruban Florin BBD | Barbados Dollar Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°