Package org.apache.torque.util
Class AvgHelper
- java.lang.Object
-
- org.apache.torque.util.AvgHelper
-
public class AvgHelper extends Object
Get's the average of a column with entries matching the provided criteria. This works similarly to the CountHelper when you need to provide additional selection criteria to compute an average. For example, limiting the average of a column in a table to a specific user.
-
-
Constructor Summary
Constructors Constructor Description AvgHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimal
avg(Criteria c, String columnName)
Returns the average of a column in a query.BigDecimal
avg(Criteria c, Connection conn, String columnName, TableMap tableMap)
Returns the average of a column in a query.BigDecimal
avg(Criteria c, Connection conn, Column column)
Returns the average of a column in a query.BigDecimal
avg(Criteria c, Column column)
Returns the average of a column in a query.
-
-
-
Method Detail
-
avg
public BigDecimal avg(Criteria c, String columnName) throws TorqueException
Returns the average of a column in a query.- Parameters:
c
- Criteria to get the count for.columnName
- Name of database Column which is counted. Preferably, use the primary key here.- Returns:
- average of the column matching the query provided
- Throws:
TorqueException
- if the query could not be executed
-
avg
public BigDecimal avg(Criteria c, Column column) throws TorqueException
Returns the average of a column in a query.- Parameters:
c
- Criteria to get the count for.column
- Name of database Column which is averaged.- Returns:
- average of the column matching the query provided
- Throws:
TorqueException
- if the query could not be executed
-
avg
public BigDecimal avg(Criteria c, Connection conn, Column column) throws TorqueException
Returns the average of a column in a query.- Parameters:
c
- Criteria to get the count for.conn
- Connection to usecolumn
- Name of database Column which is averaged.- Returns:
- average of the column matching the query provided
- Throws:
TorqueException
- if the query could not be executed
-
avg
public BigDecimal avg(Criteria c, Connection conn, String columnName, TableMap tableMap) throws TorqueException
Returns the average of a column in a query.- Parameters:
c
- Criteria to get the count for.conn
- Connection to usecolumnName
- Name of database Column which is averaged.tableMap
- the table to count the columns in, or null to determine the table automatically from the criteria.- Returns:
- average of the column matching the query provided
- Throws:
TorqueException
- if the query could not be executed.
-
-