Re: Custom sort

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Artacus <artacus(at)comcast(dot)net>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Custom sort
Date: 2008-08-15 01:58:57
Message-ID: 48A4E2E1.8010402@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Artacus wrote:
> Can you define a custom sort in postgres? For instance in mysql, you
> could do something like (I forget the exact syntax)
>
> ORDER BY FIND_IN_SET(column_name, ('one','two','three'))

The simplest direct mapping would probably be a CASE statement (see the
PostgreSQL documentation). As others have noted, enums and Pl/PgSQL
functions are also options.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nick 2008-08-15 02:06:26 Incorrect results with NOT IN
Previous Message Hui Xie 2008-08-15 01:51:45 Re: Query help