How to Find the Average of a Numeric Column in SQL Database: Standard SQL PostgreSQL MS SQL Server Oracle MS SQL Server MySQL SQLite Operators: AVG Table of Contents Problem Example Solution Discussion Find Average for Groups Using AVG with ROUND Problem You’d like to calculate the average of numbers in a given column. Example Our database has a table named sale with the following columns: id, city, year, and amount. We want to calculate the average sales, regardless of city or year. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Solution SELECT AVG(amount) as avg_amount FROM sale; Here’s the result: avg_amount 19073.125000 Discussion If you’d like to calculate the average of numeric values stored in a column, you can do so using the AVG() aggregate function. It takes one argument: the expression whose average you want to calculate. If you haven’t specified any other columns in the SELECT clause, the average will be calculated for all records in the table. Find Average for Groups Of course, since it’s an aggregate function, AVG() can also be used with groups. For example, if we’d like to find the average sale per city, we can write this query: SELECT city, AVG(amount) as avg_amount FROM sale GROUP BY city; The average is calculated for each city: cityamount Los Angeles7400.850000 Chicago30882.250000 Annandale15045.516667 Using AVG with ROUND Additionally, if the average has to be rounded, you can pass the result of the AVG() function into ROUND(): SELECT city, ROUND(AVG(amount), 2) as avg_amount FROM sale GROUP BY city; Recommended courses: SQL Basics SQL Practice Set Recommended articles: SQL Basics Cheat Sheet The SQL AVG() Function Explained With Examples How to Use the ROUND() Function in SQL Using GROUP BY in SQL SQL Aggregate Functions Cheat Sheet Top 9 SQL GROUP BY Interview Questions 19 Aggregate Function Exercises 10 GROUP BY SQL Practice Exercises with Solutions See also: How to Count Distinct Values in SQL How to Order by Count in SQL? How to Sum Values of a Column in SQL? How to Find Rows with Maximum Value How to Find the Minimum Value of a Column in SQL How to Round Numbers in SQL How to Floor Numbers in SQL Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query