---
title: "Row Vs. Range SQL Window Functions: Top Differences"
description: "ROW and RANGE window functions in SQL operate within a window, but differ in row versus value consideration."
url: https://srinimf.com/2024/04/11/row-vs-range-window-functions-top-differences-examples/
date: 2024-04-11
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/pexels-photo-7457516.jpeg?fit=1880%2C1059&ssl=1
categories: ["SQL"]
tags: ["Row Vs Range Functions"]
type: post
lang: en
---

# Row Vs. Range SQL Window Functions: Top Differences

ROW and RANGE are SQL [window functions](https://srinimf.com/2025/05/03/11-top-mysql-window-functions-with-use-cases/). These look similar but not the same. They both operate within the context of a window defined by an OVER clause in SQL queries, but they differ in how they define that window and how they calculate the result.

Related[The Most Confusing SQL Queries Made Easy (Beginner to Pro)](https://srinimf.com/2025/07/19/the-most-confusing-sql-queries-made-easy-beginner-to-pro/)

![Row Vs Range Functions](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/pexels-photo-5028854.jpeg?resize=1880%2C1253&ssl=1)*Photo by Evgenia Basyrova on Pexels.com*

## SQL Window Function: ROW

- The ROW window function operates on a physical [count of rows](https://srinimf.com/2024/01/07/oracle-count1-vs-count-top-difference/). It considers the number of rows within the window without regard to the actual values of those rows.
- It doesn’t consider the values of the rows, only the count of rows.
- Examples of ROW window functions include [ROW_NUMBER(), RANK(), and NTILE().](https://srinimf.com/2022/12/10/how-to-write-over-partition-by-sql-query/)

Example

```
-- ROW window function
SELECT
  id,
  value,
  ROW_NUMBER() OVER (ORDER BY value ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS row_number
FROM
  your_table;
```

In this query, using ROW_NUMBER(), the window function assigns a unique sequential integer to each row based solely on the order of the rows.

References

- [**SQL Window Functions**](https://www.amazon.in/SQL-Windows-Functions-Dennis-Tran-ebook/dp/B07WCTNWN9/?tag=srinimf-21)

## SQL Window Function: RANGE

- The RANGE window function operates on the actual values within the window rather than on the count of rows.
- It considers the values of the rows in the window rather than just their count.
- RANGE functions are often used with window functions that aggregate data, such as [SUM(), AVG(), MIN(), and MAX()](https://srinimf.com/2016/09/25/4-types-of-functionsto-write-better-sql-queries/).
- The window frame defined by RANGE is based on the values in the ORDER BY clause.
- RANGE functions can be sensitive to ties (rows with the same value), unlike ROW functions.
- Not all database systems support RANGE window functions.

Example

```
-- RANGE window function
SELECT
  id,
  value,
  SUM(value) OVER (ORDER BY value RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_total
FROM
  your_table;
```

In this query, using SUM() with a RANGE frame, the SQL window function calculates a running total of the ‘value’ column. The RANGE frame specifies that the window includes all rows from the beginning of the partition (UNBOUNDED PRECEDING) up to the current row.

## Conclusion

So, while both ROW and RANGE SQL window functions operate within the context of a window, they differ in how they define that window and how they calculate results.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2024%2F04%2F11%2Frow-vs-range-window-functions-top-differences-examples%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2024%2F04%2Fpexels-photo-7457516.jpeg%3Ffit%3D1200%252C676%26ssl%3D1&description=Row%20Vs.%20Range%20SQL%20Window%20Functions%3A%20Top%20Differences)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2024/04/11/row-vs-range-window-functions-top-differences-examples/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2024/04/11/row-vs-range-window-functions-top-differences-examples/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2024/04/11/row-vs-range-window-functions-top-differences-examples/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2024/04/11/row-vs-range-window-functions-top-differences-examples/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Row%20Vs.%20Range%20SQL%20Window%20Functions%3A%20Top%20Differences&body=https%3A%2F%2Fsrinimf.com%2F2024%2F04%2F11%2Frow-vs-range-window-functions-top-differences-examples%2F&share=email)
-

### Like this:

Like Loading…
