public override void Visit(AggregateFunction function) { switch (function.Type) { // cast to float (because if values are integer, result will be an integer) case AggregateFunctionEnum.Avg: _Query.Append(AVG).Append(OPENBRACE).Append(CAST).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(SPACE).Append(AS).Append(FLOAT).Append(CLOSEBRACE).Append(CLOSEBRACE); break; default: base.Visit(function); break; } }
public override void Visit(AggregateFunction function) { switch (function.Type) { // cast to double to avoid overflow exception since oracle use 128 bit number precision case AggregateFunctionEnum.Avg: _Query.Append("Round(Avg("); function.ValueExpression.Accept(this); _Query.Append("), 10)"); break; default: base.Visit(function); break; } }
public override void Visit(AggregateFunction function) { if (function.Type == AggregateFunctionEnum.Avg) { _Query.Append(AVG).Append(OPENBRACE); _Query.Append(CAST).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(AS).Append(DOUBLE_PRECISION); _Query.Append(CLOSEBRACE).Append(CLOSEBRACE); } else base.Visit(function); }
// don't add a space between the function name and the // opening parentesis, as it breaks on mysql public virtual void Visit(AggregateFunction function) { switch(function.Type) { case AggregateFunctionEnum.Count: _Query.Append(COUNT).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(CLOSEBRACE); break; case AggregateFunctionEnum.Max: _Query.Append(MAX).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(CLOSEBRACE); break; case AggregateFunctionEnum.Min: _Query.Append(MIN).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(CLOSEBRACE); break; case AggregateFunctionEnum.Avg: _Query.Append(AVG).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(CLOSEBRACE); break; case AggregateFunctionEnum.Sum: _Query.Append(SUM).Append(OPENBRACE); function.ValueExpression.Accept(this); _Query.Append(CLOSEBRACE); break; default : throw new NotImplementedException(); } }