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