pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Michael Fuhr <mike@fuhr.org>
Cc: darnold@northcoast.com
Cc: pgsql-sql@postgresql.org
Subject: Re: An order by question
Date: Sun, 01 Feb 2004 18:22:30 +0100
Message-ID: <401D35D6.2020902@klaster.net> (raw)
In-Reply-To: <20040201133451.GA13002@winnie.fuhr.org>
References: <20040201133451.GA13002@winnie.fuhr.org>

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




view thread (4+ messages)  latest in thread

Message-ID: <401D35D6.2020902@klaster.net>
Permalink:  ../401D35D6.2020902@klaster.net/
Also on:    postgresql.org/message-id/401D35D6.2020902@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, mike@fuhr.org, darnold@northcoast.com
  Subject: Re: An order by question
  In-Reply-To: <401D35D6.2020902@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox