Re: numeric SORT order

From: Doug McNaught <doug(at)wireboard(dot)com>
To: Ben Ausden <benedict(at)navyblue(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>, "'Mitch Vincent'" <mitch(at)doot(dot)org>
Subject: Re: numeric SORT order
Date: 2002-01-29 15:39:16
Message-ID: m3y9ih6uaj.fsf@varsoon.denali.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben Ausden <benedict(at)navyblue(dot)com> writes:

> thanks Mitch.
> the problem is that casting to int won't work for non-numeric data
> (obviously), and I can't guarantee that values in this column will
> definitely be numeric... I should have made that clearer in my post. Ideally
> I'd like to sort numbers in numeric order and text in regular alphabetic
> order, like: 1,2,3,40,50,a,b,c,d,e...[etc]

Then you'll need to write a custom comparison operator and do
"ORDER BY ... USING my_op".

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Darley 2002-01-29 15:47:21 Re: Moving my business to PostgreSQL
Previous Message Frank Joerdens 2002-01-29 15:31:39 Re: Multibyte encoding vs. SQL_ASCII vs. locales and European languages