From the course: Advanced SQL for Data Science: Time Series

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Moving averages

Moving averages - SQL Tutorial

From the course: Advanced SQL for Data Science: Time Series

Start my 1-month free trial

Moving averages

- In addition to working with specific data points like the average CPU utilization at a point in time, we might want to know the average utilization over the past hour at any particular point in time. That's where sliding windows come in. So let's look at how to do that. So let's select, event time and server ID. And now let's get the average CPU utilization. Now I want this for the past hour so I'm going to use the over. And now I'm going to create a clause that specifies that I want to first of all, make sure I have it in the right order so I'm going to order by event time and I want to use all the rows between the 12 preceding rows and I chose 12 because our CPU utilization measurements come in at five minute intervals. And I want to have that between the 12 preceding rows and the current row. So there are a number of terms in here like rows between, preceding and current row. So what we have here is in this over statement is it basically says order the events by event time and…

Contents