Class 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 Detail

      • Aggregations

        public Aggregations()
    • Method Detail

      • 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
      • 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
      • 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