Re: Sorting by numerical order

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, CSN <cool_screen_name90001(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Sorting by numerical order
Date: 2004-03-15 07:04:06
Message-ID: 20040315070406.GA1645@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Mar 14, 2004 at 04:59:45PM -0600, Mike Nolan wrote:
> > CSN wrote:
> > > Is it possible to have items sorted like:
> > >
> > > abc 1
> > > abc 2
> > > abc 10
> > > abc 20
> >
> > Cast them to a numeric type.
>
> You can't cast a variable char type to a numeric, though apparently

You can:

test=# select to_number('abc 1', '"abc "99');
to_number
-----------
1
(1 row)

test=# select to_number('abc 20', '"abc "99');
to_number
-----------
20
(1 row)

Karel

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edwin Pauli 2004-03-15 07:26:14 Re: PostgeSQL problem (server crashed?)
Previous Message Mike Nolan 2004-03-15 01:58:55 Re: Sorting by numerical order