[英]How to unnest multiple array columns while preserving the order of the array
在保留數組順序的同時取消嵌套包含數組的兩列的 SQL 語句是什么?
col1 | col2 |
---|---|
[1,2,3,4] | [1,2,3,4] |
預期結果
col1 | col2 |
---|---|
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
像這樣使用CROSS APPLY STRING_SPLIT
函數
select * from (
select value as Col1 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col1,'[',''),']',''),',')
)a
left join (
select value as Col2 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col2,'[',''),']',''),',')
)b on a.col1 =b.col2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.