1
到目前为止,我已经编写了一个查询,将第一行拆分为多行,但以下N行的结果将返回N行,返回空值。用于根据字符将单行数据拆分为多行的SQL
这是场景。
select address from sample;
这将返回以下4行,
Stack Overflow# is a# question and# answer site
Stack Overflow# is a# question and# answer site
Stack Overflow# is a# question and# answer site
Stack Overflow# is a# question and# answer site
当试图每一行拆分为使用下面的查询多行,
with test as (select address as str from sample)
select regexp_substr (str, '[^#]+', 1, rownum) split
from test
connect by level <= length (regexp_substr (str, '[^#]+', 1, rownum)) + 1
;
以下值将返回
。
Stack Overflow
is a
question and
answer site
(null)
(null)
(null)
为什么不能得到所有行的结果?
请为您正在使用的RDBMS添加标签。这不是标准的SQL,它需要特定于实现的答案。 – Barmar 2015-04-03 04:30:13
哦!我的错。它的Oracle – 2015-04-03 05:07:30
我很高兴看到字符串拆分问题:-)我一直在回答这个问题的大多数相关的问题。你几乎接近你想要的输出,但是你做了两件事情根本错误。查看我的答案了解更多详情。 – 2015-04-03 11:26:28