An Aggregate function calculates a summary value over a set of rows. Aggregate functions are frequently used with a Group By Clause.
primary-set-function ::=
COUNT ( * )
| COUNT ( value-expression )
| SUM ( value-expression )
| AVG ( value-expression )
| MIN ( value-expression )
| MAX ( value-expression )
These Aggregate functions are supported:
Function | Calculation |
---|---|
Count(*) | The number of rows |
Count( A ) | The number of rows where A is non-null |
Sum( A ) | The sum of A for all rows |
Avg( A ) | The average value of A for all rows |
Min( A ) | The smallest value of A for all rows |
Max( A ) | The largest value of A for all rows |
Aggregate functions can be used in:
An Aggregate function can not be used inside another Aggregate function.
1. This example returns the total number of tags in a Fernhill SCADA Database:
Select Count(*) From TagCore
2. This example provides the number of tags by type in a Fernhill SCADA Database:
Select TypeName,Count(*) From TagCore Group By TypeName
To learn more about SQL scalar value expressions.
To learn about Group By clauses.
Fernhill SCADA Structured Query Language (SQL)
To learn more about the SQL features in Fernhill SCADA.
For the meaning of terms used in Fernhill SCADA.