Select a range of rows

Select a range of rows

Situation: This is most useful if your data table does not have a primary key. You can use the table’s natural index.

Here is a way to select a range of rows. OFFSET value is the number of rows to skip (here skipping 20500 rows before returning any rows). ALL indicates the max number of rows to return.

SELECT * FROM table
LIMIT ALL OFFSET 20500

If you wanted to start on row 15 and only return 10 rows, the query would be:

SELECT * FROM table
LIMIT 10 OFFSET 15

For more content on data science, R, and Python find me on Twitter.

Previous
Next