Aggregate Functions
HelixQL provides a comprehensive set of aggregate functions for performing statistical operations and summarizing collections of values. These functions operate on arrays or collections to produce single summary values.Available Functions
MIN - Minimum Value
MAX - Maximum Value
SUM - Sum of Values
AVG - Average Value
COUNT - Count Elements
Example 1: Statistical analysis of sales data
Analyze sales performance using aggregate functions:Example 2: Student grade analysis
Calculate grade statistics for students:Example 3: Sensor data monitoring
Monitor and summarize IoT sensor readings:Common Aggregate Patterns
Combining Aggregates
Aggregate functions are often used together for comprehensive analysis:Filtered Aggregates
Combine aggregates with filtering for conditional statistics:Nested Aggregates
Calculate aggregates on aggregate results:Empty Collections
When aggregate functions are applied to empty collections:
- COUNT returns 0
- SUM returns 0
- AVG, MIN, MAX return null or error depending on implementation
Statistical Variance
To calculate variance and standard deviation, combine aggregate functions:Performance Considerations
Aggregate functions scan entire collections, so consider:
- Adding appropriate indexes for frequently aggregated fields
- Using filters before aggregation to reduce data volume
- Caching aggregate results for frequently accessed statistics
Related Topics
Unary Math Functions
SQRT, ABS, LN, LOG10, EXP, CEIL, FLOOR, ROUND
Arithmetic Functions
ADD, SUB, MUL, DIV, POW, MOD
Conditionals
Filter data before aggregation
Math Overview
Overview of all math functions