SQL Server 2008 - Sum of Sums -
i have managed write following query returns results need see occupancy , capacity floors in building.
select fma0.bldgcode, fma0.floorcode, sum(fma0.occ) occupancy, sum(case when fma0.spacetype 'a-off-%' or fma0.spacetype 'a-wks-%' fma0.capacity else 0 end) capacity fma0 fma0.bldgcode = 'tst01' group fma0.bldgcode, fma0.floorcode order fma0.bldgcode, fma0.floorcode
but need add in order column sum of "occupancy / capacity".
thks
ftd
select bldgcode, floorcode, occupancy, capacity , occupancy+capacity allsum from( select fma0.bldgcode, fma0.floorcode, sum(fma0.occ) occupancy, sum(case when fma0.spacetype 'a-off-%' or fma0.spacetype 'a-wks-%' fma0.capacity else 0 end) capacity fma0 fma0.bldgcode = 'tst01' group fma0.bldgcode, fma0.floorcode )tmp order bldgcode, floorcode
Comments
Post a Comment