ALTER VIEW [dbo].[View_QuantityManagement_Base] AS /********工程量基础表********/ select BaseId,C.ProjectId,C.DrawingId,case when a.DrawingNo is not null then a.WorkSection else b.WorkSection end as WorkSection,case when a.DrawingNo is not null then a.DrawingNo else b.ChangeNo end as DrawingNo, case when a.DrawingName is not null then a.DrawingName else b.ChangeName end as DrawingName,C.State, case when a.DrawingNo is not null then ca.ProfessionalName else cb.ProfessionalName end as Major, Part,ProjectContent,Unit,Amount,t.TeamGroupName as WorkTeam from QuantityManagement_Base C left join QuantityManagement_Drawing a on a.DrawingId=C.DrawingId left join Base_CNProfessional ca on ca.CNProfessionalId=a.Major left join QuantityManagement_Change b on b.ChangeId=C.DrawingId left join Base_CNProfessional cb on cb.CNProfessionalId=b.Major left join ProjectData_TeamGroup t on t.TeamGroupId=C.WorkTeam GO