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号