8686In the following example, `NEXT` passes the variable `customer` to the second query:
8787
8888.Passing a variable to another query via `NEXT`
89+ tag::sequential_queries_basic_example[]
8990[source,cypher]
9091----
9192MATCH (c:Customer)
9697MATCH (customer)-[:BUYS]->(:Product {name: 'Chocolate'})
9798RETURN customer.firstName AS chocolateCustomer
9899----
100+ end::sequential_queries_basic_example[]
99101
100102.Result
101103[role="queryresult",options="header,footer",cols="1*<m"]
@@ -152,6 +154,7 @@ This particularly useful when aggregating values.
152154In the following example, `NEXT` passes the variable `customer` to the second query:
153155
154156.Aggregation after `NEXT`
157+ tag::sequential_queries_aggregation_example[]
155158[source,cypher]
156159----
157160MATCH (c:Customer)-[:BUYS]->(p:Product)
162165RETURN product.name AS product,
163166 COUNT(customer) AS numberOfCustomers
164167----
168+ end::sequential_queries_aggregation_example[]
165169
166170.Result
167171[role="queryresult",options="header,footer",cols="2*<m"]
@@ -186,6 +190,7 @@ RETURN product.name AS product,
186190When a `UNION` query follows a `NEXT` the full table of intermediate results are passed into all arms of the `UNION` query.
187191
188192.`UNION` after `NEXT`
193+ tag::sequential_queries_union_example[]
189194[source,cypher]
190195----
191196MATCH (c:Customer)-[:BUYS]->(p:Product)
201206
202207RETURN * ORDER BY name, type
203208----
209+ end::sequential_queries_union_example[]
204210
205211.Result
206212[role="queryresult",options="header,footer",cols="3*<m"]
0 commit comments