Good day, Maybe someone can help me , i want to get n select output on oracle sql , but when i order by it is not correct.
code_order
1.
2.
2.1
3.
4.2
10.1
10.0
21.
21.1
23.
31.
it needs to be ordered numeric and all values has a full stop in .
any ideas??
Thanx, but i see that some values can contain non numeric values as well like C,B etc.
code_order is varchar2
使用order by to_number(code_order)
with
val as
(
SELECT '1.' as c FROM dual
union all
SELECT '2.' as c FROM dual
union all
SELECT '3.' as c FROM dual
union all
SELECT '2.1' as c FROM dual
union all
SELECT '4.2' as c FROM dual
union all
SELECT '10.1' as c FROM dual
union all
SELECT '21.' as c FROM dual
union all
SELECT '10.0' as c FROM dual
union all
SELECT '21.1' as c FROM dual
union all
SELECT '23.' as c FROM dual
union all
SELECT '31.' as c FROM dual
)
SELECT c FROM val
order by to_number(regexp_replace(c, '^(\d+)\..*$', '\1'))
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.