1.有规律的数据排序
select * from zgpf02 order by to_number(substr(sn,10)) asc

2.无规律的数据排序
order by to_number(regexp_substr(排序字段,’[0-9]*[0-9]’,1))
select * from sfc_form_list
where shift = #{shift} and ydate = #{yDate}
order by to_number(regexp_substr(lineid,'[0-9]*[0-9]',1))
本文探讨了SQL中对有规律和无规律数据进行排序的方法,包括使用`ORDER BY`结合`TO_NUMBER`和正则表达式`REGEXP_SUBSTR`进行数值提取排序。示例查询展示了如何对字符串字段中的数字部分进行排序,适用于处理复杂数据格式。
7962

被折叠的 条评论
为什么被折叠?



