Package net.sf.basedb.core.query
Class Aggregations
java.lang.Object
net.sf.basedb.core.query.Aggregations
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
count
(Expression e, boolean distinct) Calculates the number of values for an expression: new expression = COUNT(e)static Expression
Calculates the geometric mean of all values for an expression: new expression = EXP(AVG(LN(e))).static Expression
max
(Expression e) Calculates the maximum value of an expression: new expression = MAX(e)static Expression
mean
(Expression e) Calculates the arithmetic mean of all values for an expression: new expression = AVG(e)static Expression
min
(Expression e) Calculates the minimum value of an expression: new expression = MIN(e)static Expression
Calculates the quadratic mean, also called Root Mean Square, for an expression: new expression = sqrt(AVG(e*e))static Expression
sum
(Expression e) Calculates the sum of all values of an expression: new expression = SUM(e)
-
Constructor Details
-
Aggregations
public Aggregations()
-
-
Method Details
-
count
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
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
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
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
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
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
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
-