Documentation

LIMIT clause

The LIMIT clause limits the number of rows returned by a query to a specified non-negative integer.

Syntax

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

Examples

Limit results to a maximum of five rows

SELECT
  "water_level","location", "time"
FROM
  "h2o_feet" 
LIMIT
  5

View example results

Sort and limit results

Use the ORDER BY and LIMIT clauses to first sort results by specified columns, then limit the sorted results by a specified number.

SELECT
  "water_level", "location", "time"
FROM
  "h2o_feet" 
ORDER BY
  "water_level" DESC
LIMIT
  3

View example results


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: