Coding task · SQL and MySQL course · Module 10: Transactions and advanced SQL

Average price in a category

The Keeper wants to see next to each book the average price of its category. Use an aggregate with OVER and PARTITION BY.

Task

Write a query that retrieves tytul, kategoria_id and cena from the ksiazki table, and additionally adds a column aliased as srednia_kat containing the result of AVG(cena) OVER (PARTITION BY kategoria_id).