Get to know tables
OVER()
Computations with OVER()
Aggregate functions with OVER()
10. Practice 1
OVER() and WHERE
Revision

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,
  • 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.

Console

Code editor

Result

TableConsole