gpt4 book ai didi

mysql - 使用 SQL 计算方差

转载 作者:可可西里 更新时间:2023-11-01 07:37:47 27 4
gpt4 key购买 nike

我有一个金融价格时间序列:

date     price   variance_31/1/2012  1,1    n/a2/1/2012  1,2    n/a3/1/2012  1,3    4/1/2012  1,37/1/2012  1,28/1/2012  1.3

我打算使用最近 3 个价格及时计算每个日期的方差。您是否有机会仅使用 SQL 来完成此任务?

任何提示将不胜感激。

最佳答案

select  var_pop(price) as variance
from (
select price
from YourTable
order by
date desc
limit 3
) as SubQueryAlias

关于mysql - 使用 SQL 计算方差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10316171/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com