Aggregate queries

Aggregate functions are supported. The easiest way to access them is through the static Aql class. Here is a list of the most common functions:

  • “Aql.Count“ – Counts the number of records
  • “Aql.Sum” – Sums the value of one a numeric column
  • “Aql.Avg” – Calculates the average of a numeric column
  • “Aql.Max” – Returns the maximum value of a numeric column
  • “Aql.Min” – Returns the maximum value of a numeric column
  • “Aql.VarSamp” – Sample variance
  • “Aql.VarPop” – Population variance
  • “Aql.StdDevSamp” – Sample standard deviation
  • “Aql.StdDevPop” – Population standard deviation

 

Here is an example:

var q = WAFContext.Session.CreateQuery();
var alias = new AqlAliasArticleBase();
q.From(alias);
q.Select(Aql.Count(alias.NodeId));
Response.Write(q.ExecuteScalar<int>().ToString());