Format, Parameters
LIMIT keeps the first N rows of data in the data stream, and discard the rest rows.
Syntax:
- Format: limit
<number>
- Parameters: see table below
- Affected columns: data columns produced by previous UQL statements and all their homologous columns
Name | Category | Specification | Description |
---|---|---|---|
<number> |
int32 | ≥ -1 | The rows to be kept, all columns will be kept if it is -1 |
Analysis
find().nodes([1, 5]) as nodes
n(nodes).e()[:2].n() as path
limit 2
return path
In the UQL statement above, LIMIT keeps the first 2 rows of the paths resulting from template query.
See UQL statement and image below to compare Clause LIMIT and Chain Command Parameter .limit()
find().nodes([1, 5]) as nodes
n(nodes).e()[:2].n().limit(2) as path
return path
Parameter .limit() keeps the first 2 rows of paths resulting from each of the two template queries, and it keeps 4 rows from the result
Common Usage
Example: find all cards that transferred money to Card CA029, return 10 cards in a descending order of their balances; that is, to find the 10 cards with the highest balances
n({_id == "CA029"}).le({@transfer}).n({@card} as n)
with distinct (n)
order by n.balance DESC
return n{*} limit 10
Example: find all cards that transferred money to Card CA029, return them in a descending order of their balances
n({_id == "CA029"}).le({@transfer}).n({@card} as n)
with distinct (n)
limit 10 return n{*}
order by n.balance DESC