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 Details

    • AvgHelper

      public AvgHelper()
  • Method Details

    • 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 use
      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, 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 use
      columnName - 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.