sql – 在Oracle中,如何将诸如1之类的数字转换为字符串,例如“1s
发布时间:2020-12-12 08:59:00 所属栏目:MsSql教程 来源:网络整理
导读:我想将数字格式化为“1st”,“2nd”,“4th”,“9th”等.是否有Oracle函数可以为我执行此操作? 解决方法 也许我过于简单了,但似乎以下应该可以正常工作(对于整数)并且比转换为日期和返回更具可读性: select case when initial_extent is null then null when
我想将数字格式化为“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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |