Skip to content

Commit f04dcee

Browse files
hvubrsill-neo4j
andauthored
Review suggestions
Co-authored-by: Richard Sill <[email protected]>
1 parent 7e64ed7 commit f04dcee

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ This allows you to control variable scope similarly to what you can do with `WIT
149149
== Aggregation after `NEXT`
150150

151151
`NEXT` passes the result table as a whole to the subsequent query.
152-
This particularly useful when aggregating values.
152+
This is particularly useful when aggregating values.
153153

154154
In the following example, `NEXT` passes the variable `customer` to the second query:
155155

@@ -187,7 +187,7 @@ end::sequential_queries_aggregation_example[]
187187
[[union-after-next]]
188188
=== Using `UNION` after `NEXT`
189189

190-
When a `UNION` query follows a `NEXT` the full table of intermediate results are passed into all arms of the `UNION` query.
190+
If a `UNION` query follows a `NEXT` the full table of intermediate results is passed into all arms of the `UNION` query.
191191

192192
.`UNION` after `NEXT`
193193
tag::sequential_queries_union_example[]
@@ -234,7 +234,7 @@ end::sequential_queries_union_example[]
234234
[[union-before-next]]
235235
=== Using `UNION` before `NEXT`
236236

237-
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.
238238

239239
.`UNION` before `NEXT`
240240
[source,cypher]
@@ -318,7 +318,7 @@ RETURN customer.firstName AS plantCustomer
318318
[[next-and-call]]
319319
== Interactions with `CALL` subqueries
320320

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.
322322
When `NEXT` is wrapped within a `CALL` subquery, the first query gets passed only a single row at a time.
323323
This can be used to compute more complex aggregates in groups.
324324

@@ -358,13 +358,15 @@ RETURN p.name AS product,
358358
2+d|Rows: 5
359359
|===
360360

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.
362362
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.
368370

369371
[NOTE]
370372
====
@@ -375,9 +377,9 @@ The second `NEXT` passes these two rows as a whole into a query the aggregates t
375377
== Interactions with conditional queries
376378

377379
[[conditional-queries-inside-next]]
378-
=== Using conditional query before or after `NEXT`
380+
=== Using conditional queries before or after `NEXT`
379381

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.
381383
A conditional query following a `NEXT` acts equivalent to a conditional query wrapped in a `CALL` subquery.
382384

383385
.Conditional query inside `NEXT`

0 commit comments

Comments
 (0)