我稱之爲表work_type和數據的模樣:複式行轉換成列
Desc L_type Ch_ID Mod_Date
Std Process 11000 53901 2012-02-25 19:28:51.000
Not Req 16000 53901 2012-02-26 20:44:47.000
max sess 19000 53901 2012-02-25 19:44:05.000
max sess regist 19000 53901 2012-02-25 19:46:05.000
當L_TYPE有(以上數據爲防爆19000)多行則需要根據Mod_Date
最近的一次我想輸出,如:
Te_pl In_pl Vn_pl Ch_ID
Not Req max sess regist Std process 53901
我寫這樣的查詢,但它不是我想要的:
Select Case when L_type = 11000 then Desc end as Vn_pl,
Case when L_type = 16000 then Desc end as Te_pl,
Case when L_type = 11000 then Desc end as In_pl,
Ch_ID
from dbo.Work_type
的可能重複的[合併多個結果在子查詢到單個逗號分隔值(http://stackoverflow.com/questions/111341/combine-multiple-results-in-a-subquery-into-a-單逗號分隔值) – danihp 2012-03-13 15:13:11
@danihp我不認爲該請求是連接任何值加在一起。 – 2012-03-13 15:15:08