code: protected SqlNode getAggregate(SqlSelect select) {
  		SqlNode node = select.getGroup();
  		if (node != null) {
  			return node;
  		}
  		node = select.getHaving();
  		if (node != null) {
  			return node;
  		}
  		return getAgg(select);
  	}
docs: Returns the parse tree node (GROUP BY, HAVING, or an aggregate function
  call) that causes {@code select} to be an aggregate query, or null if it
  is not an aggregate query.
  
  <p>The node is useful context for error messages,
  but you cannot assume that the node is the only aggregate function.