-2

If I need select 20 to 30 rows from PostgreSQL, how can I retrieve that ?

SELECT column FROM table LIMIT 10

This is fetching top 10 rows only. Can we do this in PostgreSQL ?

Shesha
  • 1,385
  • 2
  • 14
  • 26

2 Answers2

1

Specify OFFSET in addition to LIMIT:

SELECT column FROM table LIMIT 10 OFFSET 20

You may want to use the ORDER BY clause as well as by default the rows are returned in an unspecified order.

See LIMIT and OFFSET in the PostgreSQL docs.

Eugene Yarmash
  • 119,667
  • 33
  • 277
  • 336
0

OFFSET actually just says how many rows to skip before beginning to return rows which in this case are limited to 10 rows. You just want to change the number of rows you are limiting to:

    select column from table limit 20;

or

    select column from table limit 30;
Shayna
  • 496
  • 4
  • 9