课程: Coding Exercises: SQL Data Science

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Calculating moving window average

Calculating moving window average

- As a big publishing house, your organization covers various fields and domains and financial news and market roundups is one such column. Nicholas Blake, who is a stock market analyst, is trying to test a momentum strategy on the Microsoft stock. He needs to look at the six-day moving average of the stock. Now, the challenge here is that you have to compute the six-day moving window average of the closing price of the Microsoft stock. Now moving average is a windowed computation where you compute the average over a defined period of data, and then you keep moving that window by one observation until you cover the entire dataset. So to break it down, you'll have to use the StockPrice table first of all, to get the closing price data of the Microsoft stock. Then you will use the OVER clause to set up the window. You will have to first order the data by date because that's important. And then in order to set up your…

内容