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?
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
![]() |
![]() |