# OVER Keyword

### Description

Defines a window or user-specified set of rows within functions

### Syntax

```sql
window_function() 
  OVER (
    [PARTITION BY partition_expression] 
    ORDER BY sort_expression [ASC|DESC]
    [ROWS or RANGE clause]
  )
```

### Parameters

| Parameter | Description | Required |
| --- | --- | --- |
| _PARTITION BY_ | Divides the rows into groups (partitions); The window function is applied independently to each partition | Yes |
| _ORDER BY_ | Orders rows within each partition; Important for functions like `ROW_NUMBER()`, `LEAD()`, `LAG()`, etc | Yes |
| _ROWS or RANGE_ | Defines a frame specifying which rows relative to the current row are included in the window | No |

## Example

```sql
SELECT 
  e.full_name,
  e.start_date,
  MAX(e.start_date)
    OVER (
      PARTITION BY e.department) AS max_department_start_date
FROM   
  rippling.employee.Employee e;
```

Source: https://developer.rippling.com/documentation/rippling-platform/transformations/sql-reference/over

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
