n行到n列的转换 [英] n rows to n columns conversion

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

问题描述

我的T-sql查询结果有两行有n行我需要将它们显示为n列,有2行我尝试使用pivot和rownumber()但无法得到结果可以任何人帮助我。



我的结果:



< tr>
id name
112 a
1212 b
1432 d
56756 hhh
97543 sssx




必填o / p:

< td>。
112 1212 1432 56756 97543
a b d hhh sssx

my T-sql query results two columns with n rows i need to display them as n columns with 2 rows i tried with pivot and rownumber() but unable to get the result can any one help me please.

My result:

idname
112 a
1212 b
1432 d
56756 hhh
97543 sssx
. .
. .
. .


Required o/p:
112 1212 1432 56756 97543 .. ..
a b d hhh sssx .. ..

推荐答案

请阅读: Sql Server中的动态PIVOT [ ^ ]


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆