我有一个包含5000行的庞大数据,并试图找到6月至8月期间每个城市的逐月增长率。我的数据是
id | host_id | Host_since | area
1 121 2017-08-31 LA
2 243 2017-08-15 SF
3 243 2017-06-12 SF
4 100 2017-07-13 NYC
5 300 2017-05-19 CHI
6 250 2017-07-20 MIN
7 135 2017-08-25 LA
.
.
.
我不在乎重复的host_id,我唯一想要的就是查看一个月内创建的ID总数。因此,我更正了查询,但仍然在“ OVER”附近显示错误。无法找出问题所在。不知道我在做什么错,因为查询对我来说很完美?任何帮助都会很棒。
Select strftime('%Y-%m', host_since) as month, area,
count(id) as count,
100 * (count(id) - lag(count(id), 1) over (partition by area,
order by strftime('%Y-%m', host_since))) / lag(count(id), 1) over
(partition by area, order by strftime('%Y-%m', host_since)))
as growth
from listings
where host_since between '2017-06-01' and '2017-08-31'
group by 1,2
order by 1;
SQLITE_ERROR:“结束”附近:语法错误