Progress
SQL-89
Guide and Reference
Using Aggregate Functions
Aggregate functions allow you to evaluate groups of values. In general, each function operates on the set of values in one column or on an expression. The set of column values is determined by the WHERE clause of a SELECT statement. Table 3–2 lists the SQL aggregate functions.
The following example counts all rows in the customer table.
You can include multiple aggregate functions in a single SELECT list. This example returns the average, maximum, and minimum price of items in the item table.
When aggregate functions encounter null values, they are not included in the aggregate total, with the exception of COUNT(*). COUNT(*) counts all rows, including rows that have null values.
Aggregates of columns or expressions (except for COUNT) containing no values yield NULL (the Progress unknown value), rather than 0 as in the Progress 4GL. In the following example, because no customers have negative cust-num values, the aggregate function AVG yields a value of NULL for the credit-limit field.
The following example counts the number of different countries in the customer table and the total number of rows in the table.
Aggregate functions can include arithmetic expressions, and you can use the results of aggregate functions in other operations, as shown in the following example.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |