Re: ORDER BY options (how to order data as AAA, aaa, BBB, bbb, ... ZZZ, zzz)

From: Russell Smith <mr-russ(at)pws(dot)com(dot)au>
To: Juleni <julo(at)opensubsystems(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ORDER BY options (how to order data as AAA, aaa, BBB, bbb, ... ZZZ, zzz)
Date: 2005-05-10 10:14:38
Message-ID: 200505102014.38203.mr-russ@pws.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 10 May 2005 07:41 pm, Julian Legeny wrote:
> Hello,
>
> I have following problem:

> But I would like to sort all data as following:
>
> NAME
> -----------
> AAA
> aaa
> BBB
> bbb
> CCC
> ccc
>
>
> How can I write sql command (or set up ORDER BY options) for selecting that?
>
SELECT * FROM MY_TABLE ORDER BY lower(NAME), NAME

The second NAME is to ensure that AAA comes before aaa, otherwise the order is undetermined.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ragnar Hafstað 2005-05-10 10:24:00 Re: ORDER BY options (how to order data as AAA, aaa,
Previous Message Dinesh Pandey 2005-05-10 10:10:11 Re: ORDER BY options (how to order data as AAA, aaa, BBB, bbb, ... ZZZ, zzz)