# ROWS Keyword

### Description

Specifies rows within a function

### Syntax

```sql
window_function() 
    OVER (
        [PARTITION BY partition_expression]
        ORDER BY sort_expression [ASC | DESC]
        ROWS BETWEEN frame_start AND frame_end
)
```

### Parameters

| Parameters | Description | Required |
| --- | --- | --- |
| _PARTITION BY_ | Divides rows into groups before numbering restarts in each group | No |
| _ORDER BY_ | Defines the order in which row numbers are assigned | Yes |

#### Common `ROWS` frame options

| Frame Option | Meaning |
| --- | --- |
| `ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` | From the first row in the partition to the current row |
| `ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING` | From the current row to the last row |
| `ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING` | One row before and one row after |
| `ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` | Entire partition |

### Example

```sql
SELECT 
    MIN(e.start_date) OVER (
        PARTITION BY e.department
        ORDER BY e.id
        ROWS BETWEEN UNBOUNDED PRECEDING
        AND UNBOUNDED FOLLOWING
    ) AS dates
FROM
    rippling.employee.Employee e;
```

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

> 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.
