Redshift Limit Query - How to Limit Rows Returned in Query Results

Sometimes it is useful to limit the number of rows that are returned from a query. This can be especially useful when querying very large tables.

The Amazon Redshift database provides the ability to limit the number of rows returned from a query starting at the beginning of the results using the top keyword or the limit keyword. Both top and limit provide the same functionality. Listed below are examples of limiting rows with the Redshift database:

Example 1: Returning the first 10 rows from a table called sales using the top syntax: SELECT TOP 10 * FROM SALES; Example 2: Returning the first 10 rows from a table called sales using the limit syntax: SELECT * FROM SALES LIMIT 10;

Many other databases also support limiting rows returned from queries. Listed below are links that show how to limit rows for other popular databases: