Exercise

Average, max and min functions

Let's consider the following product table:

id category name price
1 books Sapiens 12
2 electronics iPhone 12 900
3 books Measure What Matters 10
4 books Greenlights 14
5 electronics Macbook Pro 13 1500

Your goal is to calculate the maximum, minimum and average values of these products' prices, for each category.

The session and Products classes are already defined.

Instructions

100 XP
  • Import the submodule you need to perform aggregate functions in SQLAlchemy.
  • Calculate the maximum, minimum and average values of the price column.
  • Make sure you get these aggregates for each category of product.