我有一个table X
列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;
在这里,我想添加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