Ordering
Eliminating duplicate results
Aggregation
15. Find the sum
Grouping
HAVING: filtering and ordering groups
Let's practice

Instruction

That's right. The last function that we'll discuss is sum().

Examine the example:

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

The above instruction will find the total sum of all orders placed by the customer with id 100.

Exercise

Find the sum of all salaries in the Marketing department in 2014. Remember to put the department name in inverted commas!

Stuck? Here's a hint!

Type:

SELECT
  sum(salary) 
FROM employees 
WHERE year = 2014 AND department LIKE 'Marketing';