README.rows 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. -----------
  2. ROWS clause
  3. -----------
  4. Function:
  5. Limits the number of rows retrieved from a select expression. For the
  6. top-level select statement, it would mean a number of rows sent to the host
  7. program.
  8. Author:
  9. Dmitry Yemanov <[email protected]>
  10. Syntax rules:
  11. SELECT ... [ORDER BY <expr_list>] ROWS <expr1> [TO <expr2>]
  12. Scope:
  13. DSQL, PSQL
  14. Example(s):
  15. 1. SELECT * FROM T1
  16. UNION ALL
  17. SELECT * FROM T2
  18. ORDER BY COL
  19. ROWS 10 TO 100
  20. 2. SELECT COL1, COL2, ( SELECT COL3 FROM T3 ORDER BY COL4 DESC ROWS 1 )
  21. FROM T4
  22. 3. DELETE FROM T5
  23. ORDER BY COL5
  24. ROWS 1
  25. Note(s):
  26. 1. ROWS is a more understandable alternative to the FIRST/SKIP clauses with
  27. some extra benefits. It can be used in unions and all kind of subqueries.
  28. It is also available in the UPDATE/DELETE statements.
  29. 2. When <expr2> is omitted, then ROWS <expr1> is a semantical equivalent for
  30. FIRST <expr1>. When both <expr1> and <expr2> are used, then ROWS <expr1>
  31. TO <expr2> means:
  32. FIRST (<expr2> - <expr1> + 1) SKIP (<expr1> - 1). Note that there's no
  33. semantic equivalent for a SKIP clause used without a FIRST clause.
  34. 3. The ROWS-clause is not defined in the SQL standard. For SELECT, consider
  35. the alternative OFFSET and FETCH clauses defined in the SQL standard.