# Windowing

Windowing is used to smooth out random variations.

It can be used to calculate moving averages.

```
select date, sum(value) over
(order by date between rows 1 preceding and 1 following)
from sales
```

Examples of other window specifications:

* **between rows unbounded preceding and current**
* **rows unbounded preceding**
* **range between 10 preceding and current row**
  * all rows with values between current row value –10 to current value
* **range interval 10 day preceding**
  * not including current row


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/main-1/sql/advanced-sql/windowing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
