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

From Mike Nolan
Subject Re: Sorting by numerical order
Date
Msg-id 200403142259.i2EMxk1F007960@gw.tssi.com
Whole thread Raw
In response to Re: Sorting by numerical order  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Sorting by numerical order
Re: Sorting by numerical order
Re: Sorting by numerical order
Re: Sorting by numerical order
List pgsql-general
> 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 cast text to numeric.  (I'd be curious to know why one but not
the other.)

However, if I understood the original question, 'abc 1' and 'abc 20' are
contents of a single column, which might make separating out just the
numeric part tricky.

On a somewhat related subject, how difficult would it be to write an
'isnumeric' function as part of the source code as opposed to a user
function in pgsql or perl?

I have some data that is mostly numeric but not always so.  I know from
other columns whether a particular row is supposed to contain a numeric
value or not, but the data is coming from a legacy environment
and isn't 100% reliable.

An 'isnumeric(column)' boolean function in a case statment would be
very helpful so that I can program around the bad data.

I'll probably write it in perl, but would making it part of the source
code provide significantly faster execution?
--
Mike Nolan





pgsql-general by date:

Previous
From: Frank Finner
Date:
Subject: Re: PostgeSQL problem (server crashed?)
Next
From: Eric B.Ridge
Date:
Subject: Re: How reliable are the stats collector stats?