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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -