Reputation: 89
I keep getting an error when I try running this query in mysqlite3:
SELECT Region_DESC, AgeGroup, Population
(select REGION, sum(POPULATION) as Population, '0-15' AS AgeGroup
from STATS
Where Age between 0 and 15
group by REGION
union
Select REGION, SUM(POPULATION) as Population, '16-30' As AgeGroup
from STATUS
Where Age between 16 and 30
group by REGION) s
join REGION on REGION_CD = REGION
I'm getting the following error: Error: near "SELECT": syntax error
Is there anything wrong with the query, syntax-wise?
Upvotes: 0
Views: 224
Reputation: 17871
Your query is wrong. You basically have:
SELECT something
(select somethingelse FROM somethingelsetable) s
join REGION on REGION_CD = REGION
I guess you are missing FROM before the parentheses...
Upvotes: 2