我有一个带有日期,状态和某些代码(大约18至20列)的表,其中的值是1和0
Date State Test1 Test2 Test3 Test4
7/8/2019 A 1 0 1 0
7/8/2019 B 1 0 1 0
输出:
Date State Test Value
7/8/2019 A Test1 1
7/8/2019 A Test2 0
7/8/2019 A Test3 1
7/8/2019 A Test4 0
7/8/2019 B Test1 1
7/8/2019 B Test2 0
7/8/2019 B Test3 1
7/8/2019 B Test4 0
select Date,State,Test
from test
UNPIVOT (cols FOR test IN (Test1 AS 'Test1',Test2 AS 'Test2 ',Test3 AS 'Test3',Test4 AS 'Test4'))
我需要在一列中输入Test1,Test2,Test3,Test4的值