我有一个包含这些值的表格列:
Column-desc
------------------
"car broken"
"motorcycle broken"
"motorcycle clean"
"motorcycle clean and broken"
------------------
我需要做一个返回这个的选择:
return-desc1 | return-desc2 | return-desc3 |return-desc4
------------------------------------------------------
car | broken | |
motorcycle | broken | |
motorcycle | clean | |
motorcycle | clean | and | broken
-------------------------------------------------------
(是的,max ll返回4 desc)。 我可以在这种情况下使用正则表达式吗?
如果这有帮助:我正在使用Oracle 10g
答案 0 :(得分:3)
select
regexp_substr("Column-desc", '\S+', 1, 1) as "return-desc1",
regexp_substr("Column-desc", '\S+', 1, 2) as "return-desc2",
regexp_substr("Column-desc", '\S+', 1, 3) as "return-desc3",
regexp_substr("Column-desc", '\S+', 1, 4) as "return-desc4"
from your_table
答案 1 :(得分:0)
老实说,我的建议是获取column-desc并在编程层上进行拆分工作。这样会更容易,也可能更优化。