Ordering
Eliminating duplicate results
Aggregation
14. Find the average value
Grouping
HAVING: filtering and ordering groups
Let's practice

Instruction

OK, now that you know what best salary is, let's discuss another function:

SELECT
  avg(total_sum) 
FROM orders 
WHERE customer_id = 100;

The function avg() finds the average value of the specified column.

In our example, we'll get the average order value for the customer with id 100.

Exercise

Find the average salary in the table employees for the year 2013.

Stuck? Here's a hint!

Type:

SELECT
  avg(salary) 
FROM employees 
WHERE year = 2013;