>>>>> "Alvaro" == Alvaro Herrera <alvherre@commandprompt.com> writes:
Alvaro> Wow, this is really horrid:
Alvaro> # F856 through F859: FETCH FIRST clause in subqueries,Alvaro> views, and query expressions. The SQL:2008
syntaxforAlvaro> restricting the rows of a result set is FETCH FIRST, ratherAlvaro> than Microsoft SQL Server’s
SELECTTOP N equivalent whichAlvaro> SQL Anywhere supports presently.
Alvaro> This means we have to support stuff like
Alvaro> declare foo cursor for select * from lists;Alvaro> select * from (fetch first from foo) as bar;
No, that's wrong.
The new syntax is:
<query expression> ::= [ <with clause> ] <query expression body> [ <order by clause> ] [ <result offset clause> ] [
<fetchfirst clause> ]
<result offset clause> ::= OFFSET <offset row count> { ROW | ROWS }
<fetch first clause> ::= FETCH { FIRST | NEXT } [ <fetch first row count> ] { ROW | ROWS } ONLY
so it's like this:
select * from foo order by bar offset 5 rows fetch first 10 rows only;
(nothing that I can see assigns any semantics to FIRST vs NEXT, they seem
to do the same thing)
--
Andrew (irc:RhodiumToad)