title: SQL - Sum Aggregate function
body: <p>I am fairly new to SQL, so please bare that in mind.</p>
  
  <p>I have have a table with data that is divided into two centers "Toronto &amp; Montreal" for a total of 78 rows (39 per center), with multiple columns. I want to get the national total (sum) of X column for each respective center for a specific daterange (month). For example the Jan 2018 total of full time employees between Montreal + Toronto Centers combined. The logic statement for example would be to add Toronto + Montreal Jan 2018 results to yield me the national total. Although with my beginner skills I am having trouble writing a sql query that can be executed without syntax error. </p>
  
  <pre><code>select sum(fte), daterange, center
  from (
  select  'Toronto' as Center,
          sum(fte) as total fte
  from dbo.example
  where daterange = '2015-11-01'
  group by total fte
  
  union 
  
  select  'Montreal' as Center,
          sum(fte) as total fte
  from dbo.example
  where daterange = '2015-11-01'
  group by total fte
  )temptable
  group by total fte
  </code></pre>
  
  <p>The above query is giving me a error "Incorrect syntax near 'fte'." fte is a column within my table. </p>
  
  <p>Please advise me what I am doing wrong.</p>
  
  <p>Cheers!</p>