SKIP

Introduction

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.

Graph
  N0 [
    label = "name = \'A\'\l"
  ]
  N0 -> N4 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "KNOWS\n"
  ]
  N0 -> N3 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "KNOWS\n"
  ]
  N0 -> N2 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "KNOWS\n"
  ]
  N0 -> N1 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "KNOWS\n"
  ]
  N1 [
    label = "name = \'B\'\l"
  ]
  N2 [
    label = "name = \'C\'\l"
  ]
  N3 [
    label = "name = \'D\'\l"
  ]
  N4 [
    label = "name = \'E\'\l"
  ]

Skip first three rows

To return a subset of the result, starting from the fourth result, use the following syntax:

Query
MATCH (n)
RETURN n.name
ORDER BY n.name
SKIP 3

The first three nodes are skipped, and only the last two are returned in the result.

Table 1. Result
n.name

"D"

"E"

Rows: 2

Return middle two rows

To return a subset of the result, starting from somewhere in the middle, use this syntax:

Query
MATCH (n)
RETURN n.name
ORDER BY n.name
SKIP 1
LIMIT 2

Two nodes from the middle are returned.

Table 2. Result
n.name

"B"

"C"

Rows: 2

Using an expression with SKIP to return a subset of the rows

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.name
ORDER BY n.name
SKIP 1 + toInteger(3*rand())

Skip the first row plus randomly 0, 1, or 2. So randomly skip 1, 2, or 3 rows.

Table 3. Result
n.name

"B"

"C"

"D"

"E"

Rows: 4