The DB2 COLUMN functions are also known as aggregate functions. These functions take the values from a particular column of multiple rows and return a single value.
Below is the list of some most commonly used COLUMN functions.
|SUM||Finds the sum of column values|
|COUNT||Count the number of column values|
|AVG||Finds the average of column values|
|MAX||Finds the maximum value in the column|
|MIN||Finds the minimum value in the column|
The COLUMN function can only be used in the SELECT query. For example, if we have to find the average of all the ORDER_TOTAL for the orders placed on 15-08-2020 from the ORDERS table, then we can use the below query.
SELECT AVG(ORDER_TOTAL) FROM ORDERS WHERE ORDER_DATE = ‘15-08-2020’