0

当我尝试在 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

我收到以下错误:错误:“SELECT”附近:语法错误

语法方面的查询有什么问题吗?

4

3 回答 3

2

你在FROM“人口”这个词之后就不见了。

于 2013-04-13T02:17:05.477 回答
2

你的查询是错误的。你基本上有:

SELECT something
(select somethingelse FROM somethingelsetable) s
join REGION on REGION_CD = REGION

我猜你在括号之前缺少 FROM ......

于 2013-04-13T02:17:51.040 回答
0

不正确的查询 ... 第一行中缺少 From 子句。

于 2013-04-13T03:16:46.097 回答