You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a `UNION` query precedes a `NEXT` the full result of the `UNION` is passed into the subsequent query.
237
+
If a `UNION` query precedes a `NEXT` the full result of the `UNION` is passed to the subsequent query.
238
238
239
239
.`UNION` before `NEXT`
240
240
[source,cypher]
@@ -318,7 +318,7 @@ RETURN customer.firstName AS plantCustomer
318
318
[[next-and-call]]
319
319
== Interactions with `CALL` subqueries
320
320
321
-
`CALL` subqueries pass the table of intermediate rules to the subquery row-by-row, while `NEXT` passes the table as a whole.
321
+
`CALL` subqueries pass the table of intermediate results to the subquery row by row, while `NEXT` passes the table as a whole.
322
322
When `NEXT` is wrapped within a `CALL` subquery, the first query gets passed only a single row at a time.
323
323
This can be used to compute more complex aggregates in groups.
324
324
@@ -358,13 +358,15 @@ RETURN p.name AS product,
358
358
2+d|Rows: 5
359
359
|===
360
360
361
-
In this example, we compute for each non-coffee product the percentage of customers that also bought coffee.
361
+
This example computes the percentage of customers that also bought coffee for each non-coffee product.
362
362
So for each product `p`, the subquery find all pairs of a customer `c` of product `p` and another product `otherProduct` that customer has also bought.
363
-
The first `NEXT` passes these pairs as a whole into a `UNION`, so that the query can
364
-
(1) count all customers in the first arm of the union and
365
-
(2) count the customers who also bought coffee in the second arm of the union.
366
-
The `UNION` produce two rows -- one from each arm.
367
-
The second `NEXT` passes these two rows as a whole into a query the aggregates them into a single row, which is the result of the `CALL` subquery.
363
+
The first `NEXT` passes these pairs as a whole into a `UNION`, so that the query can:
364
+
365
+
. count all customers in the first arm of the union.
366
+
. count the customers who also bought coffee in the second arm of the union.
367
+
368
+
The `UNION` produces two rows -- one from each arm.
369
+
The second `NEXT` passes these two rows as a whole to a query that aggregates them into a single row, which is the result of the `CALL` subquery.
368
370
369
371
[NOTE]
370
372
====
@@ -375,9 +377,9 @@ The second `NEXT` passes these two rows as a whole into a query the aggregates t
375
377
== Interactions with conditional queries
376
378
377
379
[[conditional-queries-inside-next]]
378
-
=== Using conditional query before or after `NEXT`
380
+
=== Using conditional queries before or after `NEXT`
379
381
380
-
Conditional queries act similar to `CALL` by processing the incoming table of intermediate result row-by-row.
382
+
Conditional queries act similar to `CALL` by processing the incoming table of intermediate result row by row.
381
383
A conditional query following a `NEXT` acts equivalent to a conditional query wrapped in a `CALL` subquery.
0 commit comments