Class Aggregations

java.lang.Object
net.sf.basedb.core.query.Aggregations

public class Aggregations extends Object
A factory class to create aggregate expressions.
Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (må, 06 apr 2009) $
  • Constructor Details

    • Aggregations

      public Aggregations()
  • Method Details

    • count

      public static Expression count(Expression e, boolean distinct)
      Calculates the number of values for an expression: new expression = COUNT(e)
      Parameters:
      e - The expression to count, or null to count all rows (ie. COUNT(*))
      distinct - If only distinct values should be counted
      Returns:
      The new Expression
    • geometricMean

      public static Expression geometricMean(Expression e) throws InvalidDataException
      Calculates the geometric mean of all values for an expression: new expression = EXP(AVG(LN(e))). Note that this method can handle values less then or equal with 0 although the mathematical definition of geometric mean doesn't allow it. This is caused by the way that sql handle null values in aggregated operations. The geometric mean of the numbers [2, -5, 8] is therefor 4 (because ln(-5) is undefined, i.e. null, it is ignored in the avg operation). If you ask a mathematician he would say that the geometic mean is undefined for those numbers.
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidDataException - If the expression is null
      Since:
      2.4
    • max

      public static Expression max(Expression e) throws InvalidDataException
      Calculates the maximum value of an expression: new expression = MAX(e)
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidDataException - If the expression is null
    • min

      public static Expression min(Expression e) throws InvalidDataException
      Calculates the minimum value of an expression: new expression = MIN(e)
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidDataException - If the expression is null
    • mean

      public static Expression mean(Expression e) throws InvalidDataException
      Calculates the arithmetic mean of all values for an expression: new expression = AVG(e)
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidDataException - If the expression is null
    • sum

      public static Expression sum(Expression e) throws InvalidDataException
      Calculates the sum of all values of an expression: new expression = SUM(e)
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidDataException - If the expression is null
    • quadraticMean

      public static Expression quadraticMean(Expression e)
      Calculates the quadratic mean, also called Root Mean Square, for an expression: new expression = sqrt(AVG(e*e))
      Parameters:
      e - The expression to use in the calculation
      Returns:
      The new Expression
      Throws:
      InvalidUseOfNullException - If the expression is null
      Since:
      2.8