Re: Sorting Integer
Posted in 1993
Ruchi,
For sorting by the last two digits of an integer, how about:
select integer_num,
-(trunc(integer_num, -2) - integer_num)
from table_name
order by 2
The trunc function with a precision of -2, will change the last two digits of
the number to zeroes. Then subtracting your original number from this
truncated number and changing the sign will give you a column containing the
last two digits of your original number which you can then sort by.
Hope this is of some use!
Cathy
+-------------------------------+----------------------------------------+
| Cathy Kipp | Internet: ckipp@vth1.vth.colostate.edu |
| Veterinary Teaching Hospital | |
| Colorado State University | Voice: (303) 491-1294 |
| Fort Collins, CO 80523 | Fax: (303) 491-1205 |
+-------------------------------+----------------------------------------+