我尝试使用下面的代码,但是我无法获取每个别名的值,它只允许我对一个别名使用connect by
select regexp_substr(test_col,'[^,]+[^,]', 1,1 ) as first_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,2 ) as second_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,3 ) as third_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,4 ) as forth_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,5 ) as fifth_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,6 ) as sixth_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,7 ) as seventh_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,8 ) as eighth_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,9 ) as ninth_occur,
regexp_substr(test_col,'[^,]+[^,]', 1,10 ) as thenth_occur
from demo_live
CONNECT by
regexp_substr(test_col,'[^,]+[^,]', 1,1 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,2 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,3 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,4 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,5 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,6 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,7 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,8 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,9 )is not null,
regexp_substr(test_col,'[^,]+[^,]', 1,10 )is not null;
我只有一栏,日期看起来像:
val1,val2,,val3,val4,val5
TS1,TS2,,,,TS3,TS4,TS5
expected result:
col1 col2 col3 col4 col4
val1 val2 val3 val4 val5
TS1 TS2 TS3 TS4 TS5