What are COLUMN functions in DB2? Explain with the help of an example


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.

COLUMN FUNCTION
DESCRIPTION
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.

Example

SELECT AVG(ORDER_TOTAL) FROM ORDERS
   WHERE ORDER_DATE = ‘15-08-2020’

Updated on: 30-Nov-2020

431 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements