Mapping aggregate functions: AggrFuncMapper element
The AggrFuncMapper element is used for customizing the mappings of the aggregate functions listed in Table 10‑15. The table also shows the default template for each function.
Table 10‑15 Default templates for mapping aggregate functions
Aggregate function
Operand data types
Default template
Remarks
SUM
<INTEGER>
<DECIMAL>
<DOUBLE>
SUM ($P0)
 
AVG
AVG ($P0)
AVG (DISTINCT $P0)
 
MAX
<INTEGER>
<DECIMAL>
<DOUBLE>
<VARCHAR>
<TIMESTAMP>
MAX ($P0)
 
MIN
MIN ($P0)
 
COUNT
COUNT ($P0)
 
COUNT (*)
 
COUNT (*)
Use COUNT_ROWS as the FunctionName for COUNT (*).
Example: Mapping the AVG function
The default template for the AVG function does not return the correct result for DECIMAL data types, so you use the following mapping:
<AggrFuncMapper>
<FunctionMappings>
<FunctionMapping FunctionName="AVG"
OperandTypes="DECIMAL">
CAST(AVG( $P0 ) AS $R)
</FunctionMapping>
</FunctionMappings>
</AggrFuncMapper>