From 73cfe76c49b49c7098abbeefff551e062772ff4f Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 31 Oct 2020 20:16:49 +0300 Subject: [PATCH] Update order-by.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Удалил изменения. --- .../statements/select/order-by.md | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/docs/en/sql-reference/statements/select/order-by.md b/docs/en/sql-reference/statements/select/order-by.md index 314f41e6e5f..a4e5e3655c6 100644 --- a/docs/en/sql-reference/statements/select/order-by.md +++ b/docs/en/sql-reference/statements/select/order-by.md @@ -221,70 +221,3 @@ returns │ 1970-03-12 │ 1970-01-08 │ original │ └────────────┴────────────┴──────────┘ ``` - -## OFFSET FETCH Clause {#offset-fetch} - -`OFFSET` and `FETCH` allow you to retrieve just a portion of the rows that are generated by the rest of the query. - -``` sql -OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES} -``` - -The `FETCH` is an alternative to the [LIMIT] (../../../sql-reference/statements/select/limit.md) clause and retrieves rows from a query `SELECT` type. - -The `OFFSET` says to skip that many rows before beginning to return rows. - -For example, the following query - -``` sql -SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY -``` - -is identical to the query - -``` sql -SELECT * FROM test_fetch ORDER BY a LIMIT 3 OFFSET 1 -``` - -When using `FETCH`, it is important to use an [ORDER BY] (../../../sql-reference/statements/select/order-by.md) clause that constrains the result rows into a unique order. Otherwise, you will get an unpredictable subset of the query's rows. - -`ROW` and `ROWS` as well as `FIRST` and `NEXT` are noise words that don't influence the effects of these conditions. - -The `ONLY` option is used to return rows that immediately follow the rows omitted by the `OFFSET`. - -The `WITH TIES` option is used to return any additional rows that tie for the last place in the result set according to the `ORDER BY` clause. The `ORDER BY` is mandatory in this case. - -!!! note "Note" - According to the standard, the `OFFSET` clause must come before the `FETCH` clause if both are present. - -### Example {#example} - -Input table: - -``` text -┌─a─┬─b─┐ -│ 1 │ 1 │ -│ 2 │ 1 │ -│ 3 │ 4 │ -│ 1 │ 3 │ -│ 5 │ 4 │ -│ 0 │ 6 │ -│ 5 │ 7 │ -└───┴───┘ -``` - -Query: - -``` sql -SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY -``` - -Result: - -``` text -┌─a─┬─b─┐ -│ 1 │ 1 │ -│ 1 │ 3 │ -│ 2 │ 1 │ -└───┴───┘ -``` \ No newline at end of file