anchor.diff:  
   Such expressions can still be sensible and useful.
   
  -.aggregation functions a sub-expressions
  +.Aggregation functions as sub-expressions
   ====
   The RETURN clause
   
  
positive.code: 
  The proposed grouping and aggregation semantics is defined as a rewrite to the baseline semantics (similar to <<Simple rewrite semantics>> discussed above).
  The proposed semantics does not cover all syntactically possible queries and hence requires a syntax restriction to prohibit queries that are not covered.
  We discuss the <<Rewrite>> and the <<Syntax restriction>> in the follow two subsections.
  We simplify this discussion by ignoring row ordering and pagination as well as omitted aliases.
  Subsequently, we give a separate and brief consideration of how to these aspects fit into the proposal, cf. <<Row ordering and pagination>> and <<Omitted aliases>>, respectively.
  
  ==== Rewrite
  
  For an expression _ex_, let _AGG_(_ex_) be the set of (sub-)expressions _aggex_ of the form _agg_(_preEx_).
  
  For a <ProjectionItem> _p_ = `_postEx_ AS _al_`, let _AGG_(_p_) be the set of (sub-)expressions _aggex_ of the form _agg_(_preEx_), i.e. _AGG_(_p_) = _AGG_(_postEx_).
  
  The <ProjectionItem>s in _L_ is split according to _AGG_(_p_) in two cases
  
  * <ProjectionItem>s _p_ in _L_ is an aggregate if _AGG_(_p_) is non-empty
  * <ProjectionItem>s _p_ in _L_ is a grouping key if _AGG_(_p_) is empty
  
  For a <ProjectionItem> _p_ = `_ex_ AS _al_`,
  
  * If _AGG_(_p_) = ∅
  ** Let `_PRE_PROJ_(_p_)` be `_ex_ AS _al_`,
  ** Let `_AGGR_(_p_)` be `_al_ AS _al_`, and
  ** Let `_POST_PROJ_(_p_)` be `_al_ AS _al_`
  * If _AGG_(_p_) = {`_agg_~1~(_preEx_~1~)`, `_agg_~2~(_preEx_~2~)`, ..., `_agg~N~_(_preEx~N~_)`} with _N_ > 0
  ** Let `_PRE_PROJ_(_p_)` be `_preEx_~1~ AS _al_+++_+++1, _preEx_~2~ AS _al_+++_+++2, ..., _preEx~N~_ AS _al_+++_+++_N_`,
  ** Let `_AGGR_(_p_)` be `_agg_~1~(_al_+++_+++1) AS _al_+++_+++1, _agg_~2~(_al_+++_+++2) AS _al_+++_+++2, ..., _agg~N~_(_al_+++_+++_N_) AS _al_+++_+++_N_`, and
  ** Let `_POST_PROJ_(_p_)` be `_postEx_ AS _al_` where _postEx_ is _ex_ with each `_agg~i~_(_preEx~i~_)` in _AGG_(_p_) being replaced by `_al_+++_+++_i_` for 1 ≤ _i_ ≤ _N_.
  
negative.code: 
  * _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 an _alias_ that is 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 an alias that is different from all other aliases _x_ with (·, ·, _x_) ∈ _A_ and _x_ with (·, _x_) ∈ _K_.
  
  Assuming _K_ = {(_k_~1~, _ka_~1~), (_k_~2~, _ka_~2~), ..., (_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"]
  ----
  