ALTER view [dbo].[view_weiswysjl]
asselect distinct m.dbid,m.baogbh,m.chanpmc,m.jianymdyq,m.weitrq,(','+s.jjy+',') as jjy from mainexam m inner join (select baogbh,STUFF( (SELECT ','+jjy from secexam s2 WHERE s1.baogbh=s2.baogbh FOR XML PATH('')),1,1,'') jjy from secexam s1 ) s on m.baogbh=s.baogbh where dbstatus>0 and dbstatus!=9GO