Show TOC Start of Content Area

This graphic is explained in the accompanying text Set Functions  Locate the document in its SAP Library structure

Set functions are aggregate functions (they return one value for groups of rows and therefore imply grouping of tables).

Syntax

This graphic is explained in the accompanying text

<set function> ::= COUNT '(' '*' ')'
                          | COUNT '(' DISTINCT <value expression> ')'
                          | <general set function>.

<general set function> ::=
                   ( SUM | AVG | MIN | MAX )
                  '(' ( DISTINCT | ALL )?
<value expression> ')'.

 

The return type of set functions follow these rules:

      COUNT: The return type is exact numeric with scale 0.

      AVG: The return type is approximate numeric.

      MIN, MAX, SUM: The return type is the type of the argument.

Examples

This graphic is explained in the accompanying text

SELECT AVG(salary) FROM employees

Average. This query determines the average salary of all employees.

SELECT COUNT(*) FROM employees

COUNT(*). This query determines the number of employees.

SELECT COUNT(DISTINCT employee_name) FROM employees

Average. This query determines the number of different names of the employees.

More Information

Value expressions

End of Content Area