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: How do I sort on final digit of a number?

Re: How do I sort on final digit of a number?

From: fumi <fumi_at_tpts5.seed.net.tw>
Date: 23 Jan 2000 00:33:32 GMT
Message-ID: <86di8s$alt$7@news.seed.net.tw>

Wayne Menzie <waynem_at_bosmedtechdotcom.nospam> wrote in message news:8EC0A302Cwayneshammalammading_at_129.250.35.141...
> I have a field that I need to sort on the final digit of a number like
> this:
>
> Unsorted Sorted
> Test_id Test_id
> ------- -------
> 101 101
> 402 201
> 1401 401
> 201 1401
> 202 202
> 401 402
>
> Is there any way to do this with SQL or PL/SQL?

If your number are all numbers, use

    order by mod(test_id, 10), test_id

if not, use

    order by substr(test_id, 10), some expression Received on Sat Jan 22 2000 - 18:33:32 CST

Original text of this message

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