SQLSERVER 行轉列 用逗號隔開
select DispatchList.cDLCode,DispatchLists.cSoCode from DispatchLists,DispatchList where DispatchList.DLID=DispatchLists.DLID and cDLCode='SN2025010610016'
----------------------------下面語句是行轉列------------------------------------------------------------------------
select
l.cDLCode
,Subjects=stuff((select distinct ','+convert(varchar,DispatchLists.cSoCode)
from DispatchList,DispatchLists where DispatchList.DLID=DispatchLists.DLID and DispatchList.cDLCode=l.cDLCode
for xml path('')), 1, 1, '')
from
DispatchList l,DispatchLists where l.DLID=DispatchLists.DLID and cDLCode='SN2025010610016'
group by l.cDLCode
玉環人力網(又名玉環人才網)是玉環人才吧旗下一流的玉環人力資源招聘行業服務品牌,匯集海量玉環人才,開放玉環人才簡歷和玉環崗位,提供玉環招聘網,玉環人才市場動態行情,玉環勞務派遣,玉環培訓等,是玉環最大的人才網站。
浙公網安備 33010602011771號