It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Get to know tables
OVER()
Computations with OVER()
Aggregate functions with OVER()
9. OVER() and COUNT()
OVER() and WHERE
Summary

Instruction

Good job! You can use all aggregate functions with OVER(). Let's try an example with COUNT:

SELECT 
  id, 
  name, 
  COUNT(id) OVER()
FROM department
ORDER BY name ASC;

Here, we show the id and name of each department, plus the number of all departments. At the end, we sort the rows by name.

Exercise

For each employee that earns more than 4000, show their first_name, last_name, salary and the number of all employees who earn more than 4000.