本文介绍了如何在列中转换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



1

1

1

2

2





现在我想把它插入到另一张这样的桌子



col1 col2 col3 col4 col5

1 1 1 2 2



然后替换1 ---> Y和2 - > N $ / $


我尝试过:



SELECT col1,col2, col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15

FROM(

select * from Split('1 :1:1:1:1:1:2:2:1:2:1:1:2:1:1:',':')

)书籍

PIVOT(

FOR select * from Split('1:1:1:1:1:1:2:2:1:2:1:1:2:1:1: ',':')IN(col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15)

)结果;

row
1
1
1
2
2


now I want to insert this to another table like this

col1 col2 col3 col4 col5
1 1 1 2 2

and then replace 1 --->Y and 2-->N

What I have tried:

SELECT col1, col2, col3, col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15
FROM (
select * from Split('1:1:1:1:1:1:2:2:1:2:1:1:2:1:1:',':')
) Books
PIVOT (
FOR select * from Split('1:1:1:1:1:1:2:2:1:2:1:1:2:1:1:',':') IN (col1, col2, col3, col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15)
) Result;

推荐答案


这篇关于如何在列中转换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 07:50