SKIP
defines from which row to start including the rows in the output.
By using SKIP
, the result set will get trimmed from the top.
Please note that no guarantees are made on the order of the result unless the query specifies the ORDER BY
clause.
SKIP
accepts any expression that evaluates to a positive integer — however the expression cannot refer to nodes or relationships.
Skip first three
To return a subset of the result, starting from the fourth result, use the following syntax:
Query
MATCH (n) RETURN n ORDER BY n.name SKIP 3
The first three nodes are skipped, and only the last two are returned in the result.
Result
n |
---|
2 rows |
|
|
Try this query live create (_0 {`name`:"A"}) create (_1 {`name`:"B"}) create (_2 {`name`:"C"}) create (_3 {`name`:"D"}) create (_4 {`name`:"E"}) create (_0)-[:`KNOWS`]->(_4) create (_0)-[:`KNOWS`]->(_3) create (_0)-[:`KNOWS`]->(_2) create (_0)-[:`KNOWS`]->(_1) ; match (n) return n order by n.name skip 3
Return middle two
To return a subset of the result, starting from somewhere in the middle, use this syntax:
Query
MATCH (n) RETURN n ORDER BY n.name SKIP 1 LIMIT 2
Two nodes from the middle are returned.
Result
n |
---|
2 rows |
|
|
Try this query live create (_0 {`name`:"A"}) create (_1 {`name`:"B"}) create (_2 {`name`:"C"}) create (_3 {`name`:"D"}) create (_4 {`name`:"E"}) create (_0)-[:`KNOWS`]->(_4) create (_0)-[:`KNOWS`]->(_3) create (_0)-[:`KNOWS`]->(_2) create (_0)-[:`KNOWS`]->(_1) ; match (n) return n order by n.name skip 1 limit 2
Skip first from expression
Skip accepts any expression that evaluates to a positive integer as long as it is not referring to any external variables:
Query
MATCH (n) RETURN n ORDER BY n.name SKIP toInt(3*rand())+ 1
The first three nodes are skipped, and only the last two are returned in the result.
Result
n |
---|
3 rows |
|
|
|
Try this query live create (_0 {`name`:"A"}) create (_1 {`name`:"B"}) create (_2 {`name`:"C"}) create (_3 {`name`:"D"}) create (_4 {`name`:"E"}) create (_0)-[:`KNOWS`]->(_4) create (_0)-[:`KNOWS`]->(_3) create (_0)-[:`KNOWS`]->(_2) create (_0)-[:`KNOWS`]->(_1) ; match (n) return n order by n.name skip toInt(3*rand()) + 1