Re: An order by question

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: darnold(at)northcoast(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: An order by question
Date: 2004-02-01 17:22:30
Message-ID: 401D35D6.2020902@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dnia 2004-02-01 14:34, Użytkownik Michael Fuhr napisał:
> Consider storing the session in a separate field and assigning each
> session a value that collates in the order you want.
>
> Here's a way to order the sessions using their current format:
>
> SELECT *
> FROM records
> ORDER BY lastName,
> firstName,
> SUBSTRING(term FROM 1 FOR 4),
> CASE SUBSTRING(term FROM 5)
> WHEN 'S' THEN 1
> WHEN 'X' THEN 2
> ELSE 3
> END;

or the easier one:

order by lastname,firstname, translate(term,'SXF','123');

Regards,
Tomasz Myrta

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2004-02-01 19:11:12 Re: An order by question
Previous Message Michael Fuhr 2004-02-01 13:34:51 Re: An order by question