
日付と銘柄コードと株価が格納されているテーブルから移動平均値を求めたいのですがSQLが思い浮かびません。
テーブルは以下になります。
kabuka
| date | code |close|
| 2015-06-07 | 7974 |1000 |
| 2015-06-07 | 7974 |2000 |
私が考えたSQLはめちゃくちゃ重くて使い物になりませんでした
lang
1 select date,close, 2 (select 3 avg(b.close) 4 from kabuka b 5 where ( 6 select count(*) 7 from kabuka c 8 where c.date between b.date and a.date and c.code = a.code 9 ) between 1 and 25 AND b.code = a.code 10 having count(*) = 25) as avg25,
宜しくお願いします。

回答5件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。