Aggregate Functions (SQL)

Help Contents

Introduction

An Aggregate function calculates a summary value over a set of rows. Aggregate functions are frequently used with a Group By Clause.

Syntax

primary-set-function ::=
  COUNT ( * )
  | COUNT ( value-expression )
  | SUM ( value-expression )
  | AVG ( value-expression )
  | MIN ( value-expression )
  | MAX ( value-expression )

Remarks

These Aggregate functions are supported:

FunctionCalculation
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.

Examples

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

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.

Glossary

For the meaning of terms used in Fernhill SCADA.