code: private CouchDBQueryInterpreter onAggregatedQuery(EntityMetadata m, CouchDBQueryInterpreter interpreter,
              KunderaQuery kunderaQuery)
      {
          interpreter.setAggregation(true);
          SelectStatement selectStatement = kunderaQuery.getSelectStatement();
          Expression whereClause = selectStatement.getWhereClause();
          if (!NullExpression.class.isAssignableFrom(whereClause.getClass()))
          {
              throw new KunderaException("Aggregations with where clause are yet not supported in CouchDB");
          }
          SelectClause selectClause = (SelectClause) selectStatement.getSelectClause();
          Expression expression = selectClause.getSelectExpression();
          if (CountFunction.class.isAssignableFrom(expression.getClass()))
          {
              interpreter.setAggregationType(CouchDBConstants.COUNT);
              Expression exp = ((CountFunction) expression).getExpression();
              setAggregationColInInterpreter(m, interpreter, exp);
          }
          else if (MinFunction.class.isAssignableFrom(expression.getClass()))
          {
              interpreter.setAggregationType(CouchDBConstants.MIN);
              Expression exp = ((MinFunction) expression).getExpression();
              setAggregationColInInterpreter(m, interpreter, exp);
          }
          else if (MaxFunction.class.isAssignableFrom(expression.getClass()))
          {
              interpreter.setAggregationType(CouchDBConstants.MAX);
              Expression exp = ((MaxFunction) expression).getExpression();
              setAggregationColInInterpreter(m, interpreter, exp);
          }
          else if (AvgFunction.class.isAssignableFrom(expression.getClass()))
          {
              interpreter.setAggregationType(CouchDBConstants.AVG);
              Expression exp = ((AvgFunction) expression).getExpression();
              setAggregationColInInterpreter(m, interpreter, exp);
          }
          else if (SumFunction.class.isAssignableFrom(expression.getClass()))
          {
              interpreter.setAggregationType(CouchDBConstants.SUM);
              Expression exp = ((SumFunction) expression).getExpression();
              setAggregationColInInterpreter(m, interpreter, exp);
          }
          else
          {
              throw new KunderaException("This query is currently not supported in CouchDB");
          }
          return interpreter;
      }
docs: On aggregated query.
  
  @param m
  the m
  @param interpreter
  the interpreter
  @param kunderaQuery
  the kundera query
  @return the couch db query interpreter