解决oracle根据字段类型为字符串(中间包含数字)按顺序排序问题

select p.attribute1_,p.attribute2_,p.* from app_pay_payment p order by p.attribute1_,regexp_substr(p.attribute2_,'[^0-9]+'),to_number(regexp_substr(p.attribute2_,'[0-9]+'))

上面方法可能有些复杂 ,也可以直接用下面方法

HQL写法:cast(对象属性 as long)

SQL写法:cast(字段名 as number)

猜你喜欢

转载自koreyoshi.iteye.com/blog/1923913
今日推荐