Sql server表的格式不同 [英] Sql server table result in different format
本文介绍了Sql server表的格式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好专家。我有一个要求:
我有这种类型的表结果:
Hello experts . I have a requirement like:
I have this type of table result :
Qid AnsId AnsCount
2 1 1
2 2 3
2 3 NULL
2 4 NULL
1 5 2
1 6 1
1 7 NULL
1 8 1
但我希望它采用以下格式:
but i want it in the following format :
Qid Ans1 Ans2 Ans3 Ans4
2 1 3 0 0
1 2 1 0 1
提前谢谢。
Thank you in advance.
推荐答案
请检查Pivot功能SQL服务器。您可以从以下链接获得相关帮助: http:// msdn。 microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx [ ^ ]
问候
Pawan
Please check the Pivot feature of SQL server. You may get the relevant help from the following link http://msdn.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx[^]
Regards
Pawan
这篇关于Sql server表的格式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文