我想将数字格式化为“1st”,“2nd”,“4th”,“9th”等.是否有Oracle函数可以为我执行此操作?
解决方法
也许我过于简单了,但似乎以下应该可以正常工作(对于整数)并且比转换为日期和返回更具可读性:
select case
when initial_extent is null then null
when substr(initial_extent,-2,1) = '1'
then initial_extent || 'th'
else case substr(initial_extent,-1,1)
when '1' then initial_extent || 'st'
when '2' then initial_extent || 'nd'
when '3' then initial_extent || 'rd'
else initial_extent || 'th'
end
end as formatted_number
from user_tables
