Re: Sorting by numerical order - Mailing list pgsql-general

From Karel Zak
Subject Re: Sorting by numerical order
Date
Msg-id 20040315070406.GA1645@zf.jcu.cz
Whole thread Raw
In response to Re: Sorting by numerical order  (Mike Nolan <nolan@gw.tssi.com>)
List 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@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

pgsql-general by date:

Previous
From: Mike Nolan
Date:
Subject: Re: Sorting by numerical order
Next
From: Edwin Pauli
Date:
Subject: Re: PostgeSQL problem (server crashed?)