anchor.diff:  |2|3|5
   |===
   
  -=== Baseline aggregation
  -
  -Cypher allows grouping and aggregating (form here on just referred to as _aggregation_) the driving table in the WITH and in the RETURN clause.
  -
  -Formally, the aggregation of a driving table _D_ can be described formally as
  -pass:q[γ<sub>_K_, _A_</sub>(_D_)] where
  -
  -* _K_ is a (possibly empty) set of pairs (_k_, _al_) where
  -** _k_ is a variable -- called a _grouping key_ -- in the driving table _D_,
  -** _al_ is variable name -- also called an _alias_ -- that different from all other aliases _x_ with (·, _x_) ∈ _K_., and
  -* _A_ is a non-empty set of triple (_agg_, _x_, _al_) where
  -** _agg_ is an aggregation function and
  -** _x_ is a variable in the driving table _D_
  -** _al_ is variable name -- also called an _alias_ -- that different from all other aliases _x_ with (·, ·, _x_) ∈ _A_ or _x_ with (·, _x_) ∈ _K_.
  -
  -Assuming _K_ = {(_k_~1~, _ka_~1~), (_k_~2~, _ka_~1~), ..., (_k~N~_, _ka~N~_)} and _A_ = {(_agg_~1~, _x_~1~, _al_~1~), (_agg_~2~, _x_~2~, _al_~2~), ..., (_agg~M~_, _x~M~_, _al~M~_)}, the Cypher equivalent of pass:q[γ<sub>_K_, _A_</sub>(_D_)] is
  -
  -[source, cypher, subs="quotes"]
  -----
  -WITH _k_~1~ AS _ka_~1~, _k_~2~ AS _ka_~2~, ..., _k~N~_ AS _ka~N~_,
  -     _agg_~1~(_x_~1~) AS _al_~1~, _agg_~2~(_x_~2~) AS _al_~2~, ..., _agg~M~_(_x~M~_) AS _al~M~_
  -----
  -
  -and
  -
  -[source, cypher, subs="quotes"]
  -----
  -RETURN _k_~1~ AS _k_~1~, _k_~2~ AS _k_~2~, ..., _k~N~_ AS _k~N~_,
  -       _agg_~1~(_x_~1~) AS _al_~1~, _agg_~2~(_x_~2~) AS _al_~2~, ..., _agg~M~_(_x~M~_) AS _al~M~_
  -----
  -
  -.Baseline aggregation
  -====
  -
  -.[[Q1]]Q1
  -[source, cypher]
  -----
  -RETURN a AS a, SUM(c) AS sumC
  -----
  -
  -Grouped the driving table by `a` and computes the sum of all `c` as `sumC` for each group, so that result is:
  -
  -.Result Q1
  -|===
  -|a|sumC
  -
  -|1|7
  -|2|5
  -|===
  -====
  -
   === Baseline projection
   
  -The WITH and the RETURN clause also allow projecting the driving table including the computation of new columns (in database theory, this is called extended projection).
  +The WITH and the RETURN clause allow projecting the driving table including the computation of new columns (in database theory, this is called extended projection).
   
   The projection of a driving table _D_ can be described formally as π__~P~__(_D_) where
   
  
positive.code: 
  [NOTE]
  ====
  A less artificial example is calculating the total gross of an order as the discounted sum of line item net values (product price multiplied by amount) in query such as:
  
  .[[Q5]]Q5
  [source, cypher]
  ----
  MATCH
  (c:Customer)-[:LOCATED_IN]->(s:State)
  (c)-[:ORDERED]->(o:Order)
  (o)-[:INCLUDES]->(li:LineItem)-->(p:Product)
  RETURN s AS state, c AS customer, o AS order,
         SUM(li.amount * p.price) * c.discount * j.vat AS totalGross
  ----
  ====
  
  It has been documented on multiple occasions (e.g. cf. http://opencypher.org/articles/2017/07/27/ocig1-aggregations-article/[First oCIG Meeting]) the existing semantics or Cypher is imprecise on such queries.
  
  A precise semantics on such queries has to provide
  
  * A clear definition which <ProjectionItem>s constitute the grouping keys
  * Clear rules for which sub-expressions are allowed in <ProjectionItem>s containing aggregation functions
  
  This proposal provides a such precise semantics.
  
  
negative.code: 
  [source, cypher]
  ----
  RETURN b-a AS x, SUM(b*c) AS sumBC
  ----
  
  is effectively equivalent to
  