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?
Pardon, that would be a normalization!
As a general rule remember, it's always more easy to concatenate afterwards
(in output) than to have to split up all the time. Coding systems,
'meaningful' digits are always very dangerous.
Creating an index depends on the number of distinct values. If there are
very few, the index wouldn't be used anyway, if you are using the cost-based
optimizer. The tric site_id > 0 however usually forces the index to be used
and an implicit order by.
Regards,
--
Sybrand Bakker, Oracle DBA
Wayne Menzie <waynem_at_bosmedtechdotcom.nospam> wrote in message
news:8EC1794C7wayneshammalammading_at_129.250.35.141...
> jcmanNOSPAM_at_worldnet.att.net (Buck Turgidson) wrote in
> <865r5r$cov$1_at_bgtnsc01.worldnet.att.net>:
>
> >> >order by substr(to_char(test_id), length(to_char(test_id)))
> >>
> >> Thank you Sybrand. That does the sort on the last number perfectly.
> >>
> >> I had a suggestion to use the following:
> >>
> >> ORDER BY MOD(Test_id, 10)
> >>
> >> Would this be a more efficient means of doing this? Both seem to work
> >> properly.
> >
> >Either way, you won't use an index, so I don't think efficiency is an
> >issue, unless your CPU is an 8088, and has trouble doing the function.
>
> The last number of Test_id indicates the original site that received teh
> data. Would it be better to denormalize the database and create a field
> called site_id so I could create an index on site_id and order or select
> based on the index?
>
> Wayne Menzie
Received on Thu Jan 20 2000 - 11:46:40 CST
![]() |
![]() |