0

我需要将一行拆分为多行。

列中的样本值是这样的。

Message for status: warnings: [w1,w2] | errors: [e1,e2] | other_errors: [e3]

以上总消息在一列值中。我需要将它拆分为多行,例如

w1
w2
e1
e2
e3
  • 有人可以帮我怎么做吗?
4

1 回答 1

0

这是拆分为列的一种方法:

select
  ltrim(regexp_substr(translate(col1,'[]',',,'),',([^,]+)', 1,1) ,',') s1,
  ltrim(regexp_substr(translate(col1,'[]',',,'),',([^,]+)', 1,2) ,',') s2,
  ltrim(regexp_substr(translate(col1,'[]',',,'),',([^,]+)', 1,4) ,',') s3,
  ltrim(regexp_substr(translate(col1,'[]',',,'),',([^,]+)', 1,5) ,',') s4,
  ltrim(regexp_substr(translate(col1,'[]',',,'),',([^,]+)', 1,7) ,',') s5
from
  t1;

然后你需要取消它,SE上有很多例子。

于 2013-04-30T20:02:28.193 回答