AVG() Function

The AVG() function computes the average (mean) of numeric values in a specified column. This function is invaluable for understanding trends in datasets, particularly when analyzing performance or financial metrics. The syntax for AVG() is similar to that of SUM(): SELECT AVG(column_name) FROM table_name WHERE condition;. For example, to find the average salary of employees in a department, you would write: SELECT AVG(salary) FROM employees WHERE department_id = 20;. This function also disregards NULL values, ensuring that the average is calculated based on actual entries. By providing a single representative value, AVG() helps organizations gauge overall performance, making it easier to compare different departments or product lines. In addition, it can be used in conjunction with GROUP BY to assess average values across different categories, further enhancing analytical capabilities.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *