Aggregate Functions (SQL)

Help Contents


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:

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. To return the total number of tags in the Fernhill SCADA Database:
    Select Count(*)
    From TagCore
  2. To provide the number of tags by type in the Fernhill SCADA Database:
    Select TypeName,Count(*)
    From TagCore
    Group By TypeName

Further Information

Value Expressions (SQL)

To learn more about SQL scalar value expressions.

Group By Clause

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.