OFFSET Clause
The OFFSET clause in a SELECT query causes the result set to start some number of rows after the logical first item. The result set is numbered starting from zero, so OFFSET 0 produces the same result as leaving out the OFFSET clause. Always use this clause in combination with ORDER BY (so that it is clear which item should be first, second, and so on) and LIMIT (so that the result set covers a bounded range, such as items 0-9, 100-199, and so on).
In Impala 1.2.1 and higher, you can combine a LIMIT
clause with an OFFSET clause to produce a small result
set that is different from a top-N query, for example, to return
items 11 through 20. This technique can be used to simulate
Examples:
The following example shows how you could run a
[localhost:21000] > create table numbers (x int); [localhost:21000] > insert into numbers select x from very_long_sequence; Inserted 1000000 rows in 1.34s [localhost:21000] > select x from numbers order by x limit 5 offset 0; +----+ | x | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | +----+ Returned 5 row(s) in 0.26s [localhost:21000] > select x from numbers order by x limit 5 offset 5; +----+ | x | +----+ | 6 | | 7 | | 8 | | 9 | | 10 | +----+ Returned 5 row(s) in 0.23s
<< LIMIT Clause | UNION Clause >> | |