Back to Yugabyte Db

LIMIT

community/learn/content/01-SQL-Basics/02-fundamentals/05-limit.md

2026.1.0.0-b29868 B
Original Source

SELECT with a LIMIT clause

In this exercise we'll query the products table and return just the first 12 rows.

SELECT product_id,
       product_name,
       unit_price
FROM products
LIMIT 12;

This query should return 12 rows.

SELECT with LIMIT and OFFSET clauses

In this exercise we'll query the products table and skip the first 4 rows before selecting the next 12.

SELECT product_id,
       product_name,
       unit_price
FROM products
LIMIT 12
OFFSET 4;

This query should return 12 rows.

SELECT with LIMIT and ORDER BY clauses

In this exercise we'll query the products table, order the results in a descending order by product_id and limit the rows returned to 12.

SELECT product_id,
       product_name,
       unit_price
FROM products
ORDER BY product_id DESC
LIMIT 12;

This query should return 12 rows.