Re: How to Numerically Order varchar2 Column

From: Matt B. <mcb_at_ds.znet.com>
Date: Sat, 7 Apr 2001 22:52:35 -0700
Message-ID: <tcvv5622555hf3_at_corp.supernews.com>


[Quoted] "Freedom" <luciver_at_teleweb.at> wrote in message news:mtMz6.106274$cj.4421144_at_news.chello.at...
> I have a Table with following Data
>
> A10/1
> A10/22
> A10/3
> A10/4
> A1/10
> A11/1
> A1/11
> A11/2
> A1/12
> A11/3
> A1/13
> A11/4
> A1/14
> A11/5
>
> and I would like to sort this corectly like a number type
> A1/9
> A1/8
> A1/7
> A1/6
> A1/5
> A1/4
> A1/3
> A1/2
> A1/1
> B1/9
> B1/8
> and so on
> Can anyone help me?

SELECT my_column
FROM my_table
ORDER BY
SUBSTR(my_column,1,1), -- A,B,C,D, etc.
TO_NUMBER(my_column,2,1) -- 1/9, 1/8, 1/7, etc.

-Matt Received on Sun Apr 08 2001 - 07:52:35 CEST

Original text of this message