All Products
Search
Document Center

AnalyticDB:LIMIT

Last Updated:Mar 28, 2026

Use the LIMIT clause to control how many rows a query returns, and optionally where in the result set to start.

Syntax

SELECT select_list
FROM table_name
[ ORDER BY ... ]
{ LIMIT count | LIMIT offset, count }
ParameterDescription
countMaximum number of rows to return.
offsetNumber of rows to skip from the beginning of the result set before returning rows.

Examples

Return a fixed number of rows

The following query returns the first 5 rows from the orders table:

SELECT orderdate FROM orders LIMIT 5;

Output:

o_orderdate
-----------
1996-04-14
1992-01-15
1995-02-01
1995-11-12
1992-04-26

Skip rows and return a subset

The following query sorts the customer table by create_date and returns rows 3 through 7 (skips the first 2, then returns the next 5):

SELECT * FROM customer ORDER BY create_date LIMIT 2, 5;