README.rows 1.2 KB

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