在存储过程中如何使用嵌套大小写

时间:2018-10-03 17:18:45

标签: sql-server-2008-r2

CAST((case when (CAST(SUM(UsedQuantity) as decimal(18,2))/CAST((case when ReportingUnit=1   then (select COUNT(Id) from FloorBuildingMaster where BuildingID=fullData.BuildingID)   when ReportingUnit=2 then (select COUNT(Id) from FlatsPerFloorBuildingMaster where BuildingID=fullData.BuildingID) when ReportingUnit=3 then (select COUNT(Id) * (Select COUNT(Id) From FloorBuildingMaster Where BuildingID = fullData.BuildingID) from ColumnsBuildingMaster where BuildingID=fullData.BuildingID)    when ReportingUnit=4                then (select COUNT(Id) from FootingsBuildingMaster where BuildingID=fullData.BuildingID) when ReportingUnit=5then 1 end       
                ) as decimal(18,2)))  <= 100 then ((CAST(SUM(UsedQuantity) as decimal(18,2))/CAST((
                case when ReportingUnit=1
                then (select COUNT(Id) from FloorBuildingMaster where BuildingID=fullData.BuildingID)
                when ReportingUnit=2
                then (select COUNT(Id) from FlatsPerFloorBuildingMaster where BuildingID=fullData.BuildingID)
                when ReportingUnit=3
                then (select COUNT(Id) * (Select COUNT(Id) From FloorBuildingMaster Where BuildingID = fullData.BuildingID) from ColumnsBuildingMaster where BuildingID=fullData.BuildingID)
                when ReportingUnit=4
                then (select COUNT(Id) from FootingsBuildingMaster where BuildingID=fullData.BuildingID)
                when ReportingUnit=5
                then 1 end       
                ) as decimal(18,2)))) ELSE 100 END * (select ISNULL(SUM(ISNULL(PercentageWeightage,0)),0) from BuildingWiseSubActivityWeightage 
              where BuildingId=fullData.BuildingID and BuildingWiseSubActivityWeightage.SubActivityId=fullData.SubActivityId)/100
              )as decimal(18,2)) as Progress

0 个答案:

没有答案