Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How do I sort on final digit of a number?
A shorter way to get the last character of a string is:
order by substr(to_char(test_id), -1)
Marc
Sybrand Bakker wrote in message
<948320214.17011.0.pluto.d4ee154e_at_news.demon.nl>...
>order by substr(to_char(test_id), length(to_char(test_id)))
>should do the trick.
>
>Hth,
>
>--
>Sybrand Bakker, Oracle DBA
>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?
>>
>> Wayne Menzie
>
>
Received on Thu Jan 20 2000 - 00:47:54 CST
![]() |
![]() |