SQL AVG function
SQL AVG function Description The SQL AVG function is used to return the average of an expression in a SELECT statement. Syntax The syntax for the SQL AVG function is: SELECT AVG( expression ) FROM tables WHERE conditions; Parameters or Arguments expression can be a numeric field or formula. Example - With Single Expression For example, you might wish to know how the average cost of all products that are in the Clothing category. SELECT AVG(cost) AS "Average Cost" FROM products WHERE category = Clothing; In this SQL AVG Function example, weve aliased the AVG(cost) expression as "Average Cost". As a result, "Average Cost" will display as the field name when the result set is returned. Example - Using SQL DISTINCT You can use the SQL DISTINCT clause within the AVG function. For example, the SELECT statement below returns the combined average cost of unique cost values where the category is Clothing. SELECT AVG(DISTINCT cost) AS "Average Cost" F...