ALTER VIEW [dbo].[View_WBS_CostControlDetail] AS /********控制项明细********/ SELECT detail.CostControlDetailId, detail.CostControlId, detail.Months, detail.StartDate, detail.EndDate, c.CostControlCode, c.CostControlName, c.WbsSetId, c.ProjectId, c.Unit, --单位 c.TotalNum, --合同工作量 CONVERT(FLOAT,(select sum(ISNULL(PlanNum,0)) from WBS_CostControlDetail where CostControlId=detail.CostControlId and Months<=detail.Months and StartDate is null)) as TotalPlanNum, --累计计划完成量 CONVERT(FLOAT,(select sum(ISNULL(PlanNum,0)) from WBS_CostControlDetail where CostControlId=detail.CostControlId and ((Months