---
title: Range
description: The equivalent of Postgres' comparison operators (less than, greater than)
canonical: https://docs.paradedb.com/documentation/query-builder/term/range
---

<Note>
  For most use cases, we recommend using Postgres' native [range
  syntax](/documentation/filtering) instead.
</Note>

Finds documents containing a term that falls within a specified range of values. This produces the same results as using
Postgres' `<`, `>`, etc. range operators.

```sql
SELECT description, rating, category
FROM mock_items
WHERE rating @@@ pdb.range(int4range(1, 3, '[)'));
```

<div className="mt-8" />

<ParamField body="range" required>
  A Postgres range specifying the range of values to match the field against.
  Range types include `int4range`, `int8range`, `daterange`, `tsrange`, and
  `tstzrange`.
</ParamField>

## Inclusive vs. Exclusive Range

`pdb.range`accepts a Postgres [range type](https://www.postgresql.org/docs/current/rangetypes.html).
An inclusive lower bound is represented by `[` while an exclusive lower bound is represented by `(`. Likewise, an inclusive upper bound is represented by `]`, while an exclusive upper bound is represented by `)`.
For instance, the following query selects ratings between `1` and `3`, inclusive.

```sql
-- 1 to 3 inclusive
int4range(1, 3, '[]')

-- 1 to 3 exclusive
int4range(1, 3, '()')
```

## Unbounded Range

Passing `NULL` into either the upper or lower bound causes Postgres to treat the upper/lower bounds as
positive/negative infinity.

```sql
int4range(1, NULL, '[)')
```
