Selecting Aggregates from Procedures
Go Up to Using Select Procedures in isql
In addition to selecting values from a procedure, you can use aggregate functions. For example, to use ORG_CHART
to display a count of the number of departments, use the following statement:
SELECT COUNT(DEPARTMENT) FROM ORG_CHART;
The results are:
COUNT ============ 24
Similarly, to use ORG_CHART
to display the maximum and average number of employees in each department, use the following statement:
SELECT MAX(EMP_CNT), AVG(EMP_CNT) FROM ORG_CHART;
The results are:
MAX = |
AVG = |
5 |
2 |
If a procedure encounters an error or exception, the aggregate functions do not return the correct values, since the procedure terminates before all rows are processed.