The SQL AVG function computes the average of the values for the column( or expression) specified as an argument.
We should not give AVG function on CHAR arguments. This function operates only on numeric arguments.
The following example calculates the average salary of each department:
SELECT WORKDEPT, AVG(SALARY) FROM DSN81010.EMP GROUP BY WORKDEPT;
The AVG function is the preferred method of calculating the average of a group of values.
Although an average, in theory, is nothing more than a sum divided by a count, DB2 may not return equivalent values for AVG(COL_NAME) and SUM(COL_NAME)/COUNT(*).
The reason is that the COUNT function will count all rows regardless of value, whereas SUM ignores nulls.
Related posts
-
How a PySpark Job Executes: Understanding Statements, Stages, and Tasks
When you write a few lines of PySpark code, Spark executes a complex distributed workflow behind the scenes. Many data engineers know how to write PySpark, but fewer truly understand how statements become stages, stages become tasks, and tasks run on partitions. This blog demystifies the internal execution model of Spark by connecting these four…
-
Azure Data Factory (ADF): The Complete Beginner-Friendly Guide (2026 Edition)
Azure Data Factory (ADF) is Microsoft’s fully managed, cloud-based data integration and orchestration service. It helps you collect data from different sources, transform it at scale, and load it into your preferred analytics or storage systems. Whether you are working with Azure SQL, on-premises databases, SaaS applications, or big-data systems, ADF gives you a unified…
-
Complete Terraform CI/CD Pipeline Setup with GitHub Actions — Beginner to Advanced
The complete terraform setup example ci cd pipeline to create AWS resources using GitHub actions






