sql server关于合并列的问题 select distinct dbo.PatientInfo.ID AS 序号, dbo.PatientInfo.Name AS 姓名, dbo.PatientInfo.Age AS 年龄, dbo.PatientInfo.CaseNO AS 病历号, dbo.PatientInfo.RegistrationNO AS 登记号,dbo.PatientInfo.SerialNO AS 编号, dbo.PatientInfo.IC AS 身份证号 ,(select SUM(DateNO) from Hospitalization where Hospitalization.PatientInfoID=PatientInfo.ID) 住院天数 ,STUFF((Select ','+'宫腔粘连' from GongQiangZhanLian where PatientInfo.ID = GongQiangZhanLian.PatientInfoID for xml path ('')),1,1,'') as 病种
FROM dbo.PatientInfo
left join GongQiangZhanLian on PatientInfo.ID = GongQiangZhanLian.PatientInfoID
GO
select distinct dbo.PatientInfo.ID AS 序号, dbo.PatientInfo.Name AS 姓名, dbo.PatientInfo.Age AS 年龄, dbo.PatientInfo.CaseNO AS 病历号, dbo.PatientInfo.RegistrationNO AS 登记号,dbo.PatientInfo.SerialNO AS 编号, dbo.PatientInfo.IC AS 身份证号 ,(select SUM(DateNO) from Hospitalization where Hospitalization.PatientInfoID=PatientInfo.ID) 住院天数 ,
isnull(STUFF((Select ','+'宫腔粘连' from GongQiangZhanLian where PatientInfo.ID = GongQiangZhanLian.PatientInfoID for