The value query expression allows you to specify a scalar value derived from a nested query specification. The output of this expression is expected to be either a single value or null
.
<value query expression> ::= "VALUE" <nested query specification>
<nested query specification> ::= "{" <query specification> "}"
Details
- The query specification must conclude with a result statement that adheres to the following requirements:
- Must include a
RETURN
statement with a single return item, and must not contain aGROUP BY
clause. - The return item in the
RETURN
statement must either utilize an aggregation function or explicitly includeLIMIT 1
. If neither is specified,LIMIT 1
will be implicitly applied to ensure only a single result is returned.
- Must include a
Example Graph
The following examples run against this graph:
To create this graph, run the following query against an empty graph:
INSERT (p1:Paper {_id:'P1', title:'Efficient Graph Search', score:6}),
(p2:Paper {_id:'P2', title:'Optimizing Queries', score:9}),
(p3:Paper {_id:'P3', title:'Path Patterns', score:7}),
(p1)-[:Cites]->(p2),
(p2)-[:Cites]->(p3)
Examples
LET avgScore = VALUE {MATCH (n) RETURN avg(n.score)}
MATCH (n) WHERE n.score > avgScore
RETURN n.title
Result:
n.title |
---|
Optimizing Queries |
Path Patterns |