Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Get to know tables
OVER()
Computations with OVER()
Aggregate functions with OVER()
10. Practice 1
OVER() and WHERE
Summary

Instruction

Nice! The concept of pure OVER() might seem easy, but let's do a few more questions to be on the safe side before we move on to more complex things.

Exercise

For each purchase with department_id = 3, show its:

  • id,
  • department_id,
  • item,
  • price,
  • max – the maximum price from all purchases in this department,
  • the difference between the maximum price and the price.

Stuck? Here's a hint!

Use MAX(price) OVER() - price to calculate the difference.