# Lag
> Supported in: Batch, Faster
Returns the value of the input expression evaluated at an earlier row in the window, specifically the row that is a given number of rows before the current row. For example, with a lag of 1, this returns the value from the row immediately before the current row; with a lag of 2, it returns the value from two rows before, and so on. This lets you compare a value in the current row to a value in an earlier row without a self-join.
This requires an ordered window. The window's ordering defines which row comes before the current row, so you must specify an order for the results to be deterministic.
If the window does not contain a row that far back, such as when the current row is within the first few rows of the window, the function returns the default value, or null if no default is specified.
**Expression categories:** Aggregate
## Declared arguments
* **Expression:** Expression to lag.
*Expression\*
* *optional* **Default value:** Default value if there are fewer than 'lag' rows before the current row.
*Literal\*
* *optional* **Lag:** Number of rows to lag.
*Literal\*
**Type variable bounds:** *T accepts AnyType*
**Output type:** *T*
## Examples
### Example 1: Base case
**Argument values:**
* **Expression:** `price`
* **Default value:** *null*
* **Lag:** 1
| price | **Output** |
| ----- | ----- |
| 100 | *null* |
| 105 | 100 |
| 98 | 105 |
| 102 | 98 |
***
### Example 2: Null case
**Argument values:**
* **Expression:** `price`
* **Default value:** 0
* **Lag:** 1
| price | **Output** |
| ----- | ----- |
| 100 | 0 |
| 105 | 100 |
| 98 | 105 |
| 102 | 98 |
***
### Example 3: Edge case
**Argument values:**
* **Expression:** `price`
* **Default value:** *null*
* **Lag:** 2
| price | **Output** |
| ----- | ----- |
| 100 | *null* |
| 105 | *null* |
| 98 | 100 |
| 102 | 105 |
***