【发布时间】:2013-04-27 00:00:30
【问题描述】:
我希望计算可变日期的移动平均值。
我的数据库是结构化的:
id int
date date
price decimal
例如,我想知道过去 5 天内过去 19 天的平均价格是否高于过去 40 天的平均价格。每个时间段都是可变的。
我遇到的问题是为子查询选择特定数量的行。
Select * from table
order by date
LIMIT 0 , 19
知道每天只有 1 个输入,我可以将上面的内容用作子查询吗?之后问题似乎微不足道....
【问题讨论】:
-
你可能想使用
order by date DESC
标签: mysql sql sql-order-by average