Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Sorting varchars that contain IP addresses

Re: Sorting varchars that contain IP addresses

From: Jeremy Matthews <J.Matthews_at_BTInternet.com>
Date: 1997/07/27
Message-ID: <01bc9abc$30418260$f92f63c3@one>#1/1

AMARENDRA B NETTEM <nettama_at_charlie.cns.iit.edu> wrote in article <33D8F04E.324A_at_charlie.cns.iit.edu>...
> Steve Dover wrote:
> >
> > Joe Whalley wrote:
> > >
> > > I am trying to retrieve a list of IP numbers that are stored as
> > > character strings. When I sort them, I want them in "numerical"
 order,
> > > but since they are strings, they get sorted as text, e.g.:
> > >
> > > 129.83.149.10
> > > 129.83.149.11
> > > 129.83.149.2
> > > 129.83.149.21
> > >
> > > What I want is:
> > > 129.83.149.2
> > > 129.83.149.10
> > > 129.83.149.11
> > > 129.83.149.21
> > >
> > > Any good ideas?
> > >
> > > Thanks - Joe
>
>
>

Hi Joe
Try :-
select * from table
order by TO_NUMBER(replace(IP,'.',''))

It is a bit shorter and more generic than using substr

Jeremy Matthews
Goldmoor Computing
London Received on Sun Jul 27 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US