select qh.CaseId ,(select sh.CaseId from ServiceQuot.dbo.Header sh where qh.QutoNo = sh.HeaderNo) ,qh.ApplierDate ,qh.BU ,qh.Site , qh.HeaderNo , qh.Currency (select sh.Customer from ServiceQuot.dbo.Header sh where qh.QutoNo = sh.HeaderNo) , qh.PN ,qh.QutoNo ,(select sum(ql.Num) from QAPriceContrast.dbo.Line ql where ql.CaseId = qh.CaseId) ,( select ( select sdl.SPMCost from ServiceQuot.dbo.Line sdl where qh.QutoLineId = sdl.LineId and shf.CaseId = sdl.CaseId) SpmCost from ServiceQuot.dbo.Header shf where qh.QutoNo = shf.HeaderNo ) ,qh.CalQutoHumanCost ,qh.CalQuotMaterilCost ,qh.CalQuotOtherPrice ,qh.CalQutoCostCount ,qh.CalActualHumanCost ,qh.CalActualMaterialCost ,qh.ActualOtherPrice ,qh.CalActualCostCount ,qh.CalQutoHumanCost - qh.CalActualHumanCost ,qh.CalQuotMaterilCost - qh.CalActualMaterialCost ,qh.CalQuotOtherPrice - qh.ActualOtherPrice ,(qh.CalQutoHumanCost - qh.CalActualHumanCost) + (qh.CalQuotMaterilCost - qh.CalActualMaterialCost) + (qh.CalQuotOtherPrice - qh.ActualOtherPrice) , CONCAT( cast (((qh.CalQutoCostCount - qh.CalActualCostCount) / qh.CalActualCostCount) * 100 as numeric(10, 2)),'%') from QAPriceContrast.dbo.Header qh where qh.CalActualCostCount is not null
标签:dbo,CaseId,Cast,sh,Concat,小数位,qh,where,select From: https://www.cnblogs.com/lixia0604/p/17869079.html