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

Instruction

Nice! The basic concept of pure OVER() might seem easy, but let's do a couple of exercises before we move on to this clause's more complicated usage.

Exercise

For each purchase with DepartmentId = 3, show the:

  • Id,
  • DepartmentId,
  • Item,
  • Price,
  • maximum price of all purchases in this department (as MaxPrice),
  • the difference between the maximum price and the item price (as Difference).

Stuck? Here's a hint!

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