---
title: LIMIT and SLIMIT clauses
description: Use the LIMIT and SLIMIT clauses to limit the number of points and series returned in queries.
url: https://docs.influxdata.com/influxdb/v2/query-data/influxql/explore-data/limit-and-slimit/
estimated_tokens: 5448
product: InfluxDB OSS v2
version: v2
---

# LIMIT and SLIMIT clauses

This page documents an earlier version of InfluxDB OSS. [InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

#### API token hashing is enabled by default in InfluxDB OSS 2.9.0

Stronger token security: tokens are stored as hashes on disk, so a copy of the database file doesn’t expose usable tokens. Existing tokens are hashed on first startup and the original strings can’t be recovered afterward — **capture any plaintext tokens you still need before you upgrade**.

For more information, see [Token hashing](/influxdb/v2/admin/tokens/#token-hashing).

Use `LIMIT` and `SLIMIT` to limit the number of [points](/influxdb/v2/reference/glossary/#point) and [series](/influxdb/v2/reference/glossary/#series) returned per query.

-   [LIMIT clause](#limit-clause)
    -   [Syntax](#syntax)
    -   [Examples](#examples)
-   [SLIMIT clause](#slimit-clause)
    -   [Syntax](#syntax-1)
    -   [Examples](#examples-2)
-   [Use LIMIT and SLIMIT together](#use-limit-and-slimit-together)

## LIMIT clause

`LIMIT <N>` returns the first `N` points from the specified [measurement](/influxdb/v2/reference/glossary/#measurement).

### Syntax

```sql
SELECT_clause FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] LIMIT <N>
```

`N` specifies the number of points to return from the specified measurement . If `N` is greater than the number of points in a measurement, InfluxDB returns all points from the measurement.

**IMPORTANT:** The `LIMIT` clause must appear in the order outlined in the syntax above.

### Examples

[](#limit-the-number-of-points-returned)

Limit the number of points returned

```sql
SELECT "water_level","location" FROM "h2o_feet" LIMIT 3
```

Output:

Name: h2o\_feet

| time | water_level | location |
| --- | --- | --- |
| 2019-08-17T00:00:00Z | 8.1200000000 | coyote_creek |
| 2019-08-17T00:00:00Z | 2.0640000000 | santa_monica |
| 2019-08-17T00:06:00Z | 8.0050000000 | coyote_creek |

The query returns the three oldest points, determined by timestamp, from the `h2o_feet` [measurement](/influxdb/v2/reference/glossary/#measurement).

[](#limit-the-number-of-points-returned-and-include-a-group-by-clause)

Limit the number of points returned and include a `GROUP BY` clause

```sql
SELECT MEAN("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:42:00Z' GROUP BY *,time(12m) LIMIT 2
```

Output:

name: h2o\_feet  
tags: location=coyote\_creek

| time | mean |
| --- | --- |
| 2019-08-18T00:00:00Z | 8.4615000000 |
| 2019-08-18T00:12:00Z | 8.2725000000 |

name: h2o\_feet  
tags: location=santa\_monica

| time | mean |
| --- | --- |
| 2019-08-18T00:00:00Z | 2.3655000000 |
| 2019-08-18T00:12:00Z | 2.3360000000 |

This query uses the InfluxQL [MEAN() function](/influxdb/v2/query-data/influxql/functions/aggregates/#mean) and a `GROUP BY` clause to calculate the average `water_level` for each [tag](/influxdb/v2/reference/glossary/#tag) and for each 12-minute interval in the queried time range. `LIMIT 2` requests the two oldest 12-minute averages (determined by timestamp).

Note that without `LIMIT 2`, the query would return four points per series; one for each 12-minute interval in the queried time range.

## SLIMIT clause

`SLIMIT <N>` returns every [point](/influxdb/v2/reference/glossary/#point) from `N` [series](//influxdb/v2/reference/glossary/#series) in the specified [measurement](/influxdb/v2/reference/glossary/#measurement).

### Syntax

```sql
SELECT_clause FROM_clause [WHERE_clause] GROUP BY *[,time(<time_interval>)] [ORDER_BY_clause] SLIMIT <N>
```

`N` specifies the number of series to return from the specified measurement. If `N` is greater than the number of series in a measurement, InfluxDB returns all series from that measurement.

`SLIMIT` queries must include `GROUP BY *`. Note that the `SLIMIT` clause must appear in the order outlined in the syntax above.

### Examples

[](#limit-the-number-of-series-returned)

Limit the number of series returned

```sql
SELECT "water_level" FROM "h2o_feet" GROUP BY * SLIMIT 1
```

Output:

name: h2o\_feet  
tags: location=coyote\_creek

| time | water_level |
| --- | --- |
| 2019-08-17T00:00:00Z | 8.1200000000 |
| 2019-08-17T00:06:00Z | 8.0050000000 |
| 2019-08-17T00:12:00Z | 7.8870000000 |
| 2019-08-17T00:18:00Z | 7.7620000000 |
| 2019-08-17T00:24:00Z | 7.6350000000 |
| 2019-08-17T00:30:00Z | 7.5000000000 |
| 2019-08-17T00:36:00Z | 7.3720000000 |

The results above include only the first few rows, as the data set is quite large. The query returns all `water_level` [points](/influxdb/v2/reference/glossary/#point) from one of the [series](/influxdb/v2/reference/glossary/#series) associated with the `h2o_feet` [measurement](/influxdb/v2/reference/glossary/#measurement).

[](#limit-the-number-of-series-returned-and-include-a-group-by-time-clause)

Limit the number of series returned and include a `GROUP BY time()` clause

```sql
SELECT MEAN("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:42:00Z' GROUP BY *,time(12m) SLIMIT 1
```

Output:

name: h2o\_feet  
tags: location=coyote\_creek

| time | mean |
| --- | --- |
| 2019-08-18T00:00:00Z | 8.4615000000 |
| 2019-08-18T00:12:00Z | 8.2725000000 |
| 2019-08-18T00:24:00Z | 8.0710000000 |
| 2019-08-18T00:36:00Z | 7.8330000000 |

The query uses the InfluxQL [MEAN() function](/influxdb/v2/query-data/influxql/functions/aggregates/#mean) and a time interval in the [GROUP BY clause](/influxdb/v2/query-data/influxql/explore-data/group-by/) to calculate the average `water_level` for each 12-minute interval in the queried time range.

`SLIMIT 1` requests a single series associated with the `h2o_feet` measurement.

Note that without `SLIMIT 1`, the query would return results for the two series associated with the `h2o_feet` measurement: `location=coyote_creek` and `location=santa_monica`.

## Use LIMIT and SLIMIT together

`LIMIT <N>` followed by `SLIMIT <2>` returns the first `N1` [points](/influxdb/v2/reference/glossary/#point) from `N2` series in the specified measurement.

### Syntax

```sql
SELECT_clause FROM_clause [WHERE_clause] GROUP BY *[,time(<time_interval>)] [ORDER_BY_clause] LIMIT <N1> SLIMIT <N2>
```

`N1` specifies the number of points to return per measurement. If `N1` is greater than the number of points in a measurement, InfluxDB returns all points from that measurement.

`N2` specifies the number of series to return from the specified measurement. If `N2` is greater than the number of series in a measurement, InfluxDB returns all series from that measurement.

`SLIMIT` queries must include `GROUP BY *`. Note that the `SLIMIT` clause must appear in the order outlined in the syntax above.

### Examples

[](#limit-the-number-of-points-and-series-returned)

Limit the number of points and series returned

```sql
SELECT "water_level" FROM "h2o_feet" GROUP BY * LIMIT 3 SLIMIT 1
```

Output:

Name: h2o\_feet  
Tags: location=coyote\_creek

| time | water_level |
| --- | --- |
| 2019-08-17T00:00:00Z | 8.1200000000 |
| 2019-08-17T00:06:00Z | 8.0050000000 |
| 2019-08-17T00:12:00Z | 7.8870000000 |

The query returns the three oldest points, determined by timestamp, from one of the series associated with the measurement `h2o_feet`.

[](#limit-the-number-of-points-and-series-returned-and-include-a-group-by-time-clause)

Limit the number of points and series returned and include a `GROUP BY time()` clause

```sql
SELECT MEAN("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:42:00Z' GROUP BY *,time(12m) LIMIT 2 SLIMIT 1
```

Output:

Name: h2o\_feet  
Tags: location=coyote\_creek

| time | mean |
| --- | --- |
| 2019-08-18T00:00:00Z | 8.4615000000 |
| 2019-08-18T00:12:00Z | 8.2725000000 |

The query uses the InfluxQL function MEAN() and a time interval in the GROUP BY clause to calculate the average `water_level` for each 12-minute interval in the queried time range. `LIMIT 2` requests the two oldest 12-minute averages (determined by timestamp) and `SLIMIT 1` requests a single series associated with the `h2o_feet` measurement.

Note that without `LIMIT 2 SLIMIT 1`, the query would return four points for each of the two series associated with the `h2o_feet` measurement.
