0
我有表格式多行加入
Id QId ResourceId ModuleId SubProjId Comments
1 1 1 1 2 ffdg 1 1
2 2 1 1 2 dfgfdg 1 1
3 3 1 1 2 hgjhg 1 1
4 1 2 1 2 tryty 1 0
5 5 1 1 2 sdf 1 1
6 5 2 1 2 ghgfh 1 0
7 7 2 1 2 tytry 1 0
8 3 2 1 2 rytr 1 0
,我婉導致這樣
qid ResourceId Comments ResourceId Comments
1 1 ffdg 2 tryty
3 1 hgjhg 2 rytr
我試圖
select distinct A.qid,A.ResourceId,A.Comments,B.ResourceId,b.Comments
from dbo.#temp A inner join #temp B on A.QId=B.QId and A.[ModuleId]=B.[ModuleId] and a.[SubProjId]=b.[SubProjId]
,但沒有發現任何運氣請幫忙
我希望這個線程可以幫助你。 http://stackoverflow.com/questions/4071811/how-to-transform-vertical-data-into-horizontal-data-with-sql – Pavan 2011-12-14 05:41:59
解釋結果出來的基礎。 – 2011-12-14 05:42:44