I am fairly new to SQL, so please bare that in mind.
I have have a table with data that is divided into two centers "Toronto & 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.
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
The above query is giving me a error "Incorrect syntax near 'fte'." fte is a column within my table.
Please advise me what I am doing wrong.
Cheers!
total fte, like'total fte'dbo.example; thedboschema is usually associated with SQL Server and not MySQL.