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
-
Ingesting Data from AWS S3 into Databricks with Auto Loader: Building a Medallion Architecture
In this blog post, we will explore how to seamlessly ingest data from Amazon S3 into Databricks using Auto Loader. We will also discuss performing transformations on the data and implementing a Medallion architecture for better management and processing of large datasets. What is the Medallion Architecture? The Medallion architecture is a data modeling pattern…
-
Exploring Databricks Unity Catalog – System Tables and Information _Schema: Use Cases
Databricks Unity Catalog offers a unified governance solution for managing structured data across the Databricks Lakehouse platform. It enables organizations to implement fine-grained access controls, auditing, and monitoring, enhancing data governance and compliance. Key functionalities include centralized metadata management, data discovery, dynamic reporting, and data lineage tracking, optimizing performance and collaboration.






