Add support for FETCH/OFFSET syntax
See original GitHub issueIn terms of syntax, this is what the spec says:
A <query expression> can also optionally contain a <result offset clause>,
which may limit the cardinality of the derived table by removing a specified
number of rows from the beginning of the derived table. If a <query expression>
contains both an <order by clause> and a <result offset clause>, then the rows
in the derived table are first sorted according to the <order by clause> and then
limited by dropping the number of rows specified in the <result offset clause>
from the beginning of the result produced by the <query expression>. If the
cardinality of the result of an evaluation of a <query expression> is less than
the offset value specified by a <result offset clause>, then the derived table is empty.
And
<query expression> ::=
[ <with clause> ] <query expression body>
[ <order by clause> ] [ <result offset clause> ] [ <fetch first clause> ]
<result offset clause> ::=
OFFSET <offset row count> { ROW | ROWS }
<fetch first clause> ::=
FETCH { FIRST | NEXT } [ <fetch first quantity> ] { ROW | ROWS } { ONLY | WITH TIES }
<fetch first quantity> ::=
<fetch first row count>
| <fetch first percentage>
<offset row count> ::=
<simple value specification>
<fetch first row count> ::=
<simple value specification>
<fetch first percentage> ::=
<simple value specification> PERCENT
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Add support for FETCH/OFFSET syntax · Issue #1 · trinodb/trino
Do we want to support simplified syntax OFFSET n LIMIT m as well? Yes, that would fall out naturally from having LIMIT be...
Read more >SQL Server OFFSET FETCH: Limit The Number of Rows ...
In this syntax: The OFFSET clause specifies the number of rows to skip before starting to return rows from the query. The offset_row_count...
Read more >fetchOffset | Apple Developer Documentation
This setting allows you to specify an offset at which rows will begin being returned. Effectively, the request skips the specified number of...
Read more >SQL | OFFSET-FETCH Clause - GeeksforGeeks
Syntax : SELECT column_name(s) FROM table_name ORDER BY ... See your article appearing on the GeeksforGeeks main page and help other Geeks.
Read more >Error while using FETCH/OFFSET fucntion in SQL
You have to use LIMIT instead of FETCH NEXT rows as it is not MySQL syntax. Also go through the following link where...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that would fall out naturally from having LIMIT be an alternate form of FETCH FIRST/NEXT.
Agreed. That’s confusing. Let’s not add it for now. We can always expand later.
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax As above, the syntax is almost fully interchangeable for non-trivial queries, save for the ordering of limit and offset (offset being part of the limit clause, same with Postgres syntax https://www.postgresql.org/docs/8.1/queries-limit.html which I know presto already translates to).
edit: seems as though this is standard with impala as well http://impala.apache.org/docs/build/html/topics/impala_offset.html