Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Ordering
Limiting the output
Eliminating duplicate results
Aggregation
17. 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(TotalSum) AS EntireTotal
FROM Order
WHERE CustomerId = 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 quotes! Name the column TotalSalary.

Stuck? Here's a hint!

Type:

SELECT
  SUM(Salary) AS TotalSalary
FROM Employee
WHERE Year = 2014
  AND Department = 'Marketing';