> ## Documentation Index
> Fetch the complete documentation index at: https://offthepace.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# trailing_window_frame

> Builds the OVER(...) frame shared by trailing_median and trailing_observation_count.

Builds the OVER(...) frame shared by trailing\_median and trailing\_observation\_count. The frame ALWAYS ends at `1 PRECEDING`. That is the whole point: it is what makes the window backward-only, so a row is never scored against a value it could not have seen. Do not add a variant that ends at CURRENT ROW -- a baseline that includes the lap it scores is a different statistic, and the two must not share a name.

## Signature

```sql theme={null}
{{ trailing_window_frame(partition_by, order_by, lookback=none, frame='rows') }}
```

## Arguments

| Argument | Description |
| - | - |
| `partition_by` | list of column names, or a raw string, or none for an UNPARTITIONED window (one global series -- e.g. the pooled shrinkage prior in int\_sc\_hazard\_history, which is a rate across all circuits and so has no entity to partition by). `none` is not the same as omitting the |
| `argument` | it is a deliberate "the whole table is one series". |
| `order_by` | list of column names, or a raw string (the time axis) |
| `lookback` | integer N for `N PRECEDING`, or none for `UNBOUNDED PRECEDING` |
| `frame` | 'rows' or 'range'. ROWS counts rows; RANGE counts values of the ORDER BY column, which is what a FIELD statistic across several entities at the same time index needs (see 02g), and what a SEASON-lagged statistic needs when a season may hold many rows (02d). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.