Answer: Aggregate Records Using AVG
Explore how to apply the AVG aggregate function in SQL to calculate average values for grouped data. Understand key concepts like SELECT, FROM, GROUP BY clauses, aliases, and aggregate functions. This lesson helps you write efficient queries to compute averages per category and introduces alternate query approaches for varied scenarios.
Solution
The solution is given below:
Explanation
The explanation of the solution code is given below:
Line 2: The
SELECTquery selects theCategorycolumn and the average price of thePricecolumn by calculating it using theAVGfunction. We useASto set an alias for the column.Line 3: The
FROMclause specifies the table,Products. ...