![](/img/trans.png)
[英]Calculate average, variance and standard deviation of two numbers in two different rows/columns with sql / PHP on specific dates
[英]calculate variance using SQL
我有一個金融價格時間序列:
date price variance_3 1/1/2012 1,1 n/a 2/1/2012 1,2 n/a 3/1/2012 1,3 4/1/2012 1,3 7/1/2012 1,2 8/1/2012 1.3
我打算使用最近的三個時間來計算每個日期的差異。 您是否有機會僅使用SQL完成此操作?
任何提示將不勝感激。
select var_pop(price) as variance
from (
select price
from YourTable
order by
date desc
limit 3
) as SubQueryAlias
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.