0
我試圖將多行組合成一行。如何在ms中將列信息組合成一行SQL Server Management 2005
例
Office 1 NULL NULL 12/15/2020
Office 1 NULL 10/15/2008 NULL
Office 1 1949885 NULL NULL
我使用的內用case語句加入到查詢的信息。我只是想不出如何將所有的數據合併成一排
我希望我的結局是這個
Office 1 1949885 10/15/2008 12/15/2020
這裏是我的查詢
select distinct GroupName, (case when userid=1 then data end) as TPI,
(case when userid=4 then data end) as Enrollment_Date,
(case when userid=19 then data end) as Expiration_Date
from offices
inner join userdefinedoff uo on uo.OfficeID=Offices.OfficeID
where userid=1 or userid=4 or userid=19
所有數字數據存儲爲串。
曾任職完美。謝謝! – ryanb082
@ ryanb082:很高興它幫助..我建議看看這個鏈接,以便它可以幫助你如何提出未來的問題,並且你也可以得到upvotes:https://spaghettidba.com/2015/04/ 24 /如何到後在-SQL的問題上,一個公開論壇/ – TheGameiswar