Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Show CAS, USD first; the left ordered by currency name


  • From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
  • To: pgsql-sql(at)postgresql(dot)org
  • Subject: Re: Show CAS, USD first; the left ordered by currency name
  • Date: Fri, 31 Jul 2009 13:37:02 +0200
  • Message-id: <pu1vnxkrs1.fsf@srv.protecting.net> <text/plain>

In article <4A71F9CB(dot)9050805(at)encs(dot)concordia(dot)ca>,
Emi Lu <emilu(at)encs(dot)concordia(dot)ca> writes:

> 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
> ...

Probably the shortest solution is

  SELECT code, description
  FROM currency
  ORDER BY code != 'CAD', code != 'USD', code;

BTW: your data are obsolete.  Andorra has the Euro.




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group