我有一个table X
with 列a, seq_no, dept_no, status
,其中column a
包含诸如"1,2,3,4,5,6"
. 要将行更改为列,我将查询用作:
SELECT DISTINCT TO_NUMBER(regexp_substr(a,'[^,]+',1,level)) numbers
FROM x
CONNECT BY TO_NUMBER(regexp_substr(a,'[^,]+',1,level)) IS NOT NULL;
在这里,我想添加类似 where 的条件dept_no is null and seq_no=1 and status='U'
。如何添加上述条件。
从评论编辑:
我试过了:
SELECT DISTINCT TO_NUMBER(regexp_substr(a,'[^,]+',1,level)) numbers
FROM x
WHERE seq_no=1
AND status='U'
START WITH dept_no IS NULL
CONNECT BY TO_NUMBER(regexp_substr(a,'[^,]+',1,level)) IS NOT NULL