在 SQL Server 中,您可以应用以下UNPIVOT
功能:
select value, col
from yourtable
unpivot
(
value
for col in ([Donna F. Carreras], [Alexander J. Deborde],
[John Ford], [Marjorie M. Lee], [Crystal C Zhu])
) un
请参阅带有演示的 SQL Fiddle
或者您可以使用UNION ALL
查询:
select [Donna F. Carreras] value, 'Donna F. Carreras' col
from yourtable
union all
select [Alexander J. Deborde] value, 'Alexander J. Deborde' col
from yourtable
union all
select [John Ford] value, 'John Ford' col
from yourtable
union all
select [Marjorie M. Lee] value, 'Marjorie M. Lee' col
from yourtable
union all
select [Crystal C Zhu] value, 'Crystal C Zhu' col
from yourtable
请参阅带有演示的 SQL Fiddle
两者都产生相同的结果:
| VALUE | COL |
--------------------------------
| 176 | Donna F. Carreras |
| 246 | Alexander J. Deborde |
| 312 | John Ford |
| 502 | Marjorie M. Lee |
| 19969 | Crystal C Zhu |