Aggregate Functions vs Window Functions: Real-World
Module: Aggregate Functions & Grouping
Window functions preserve detail while adding context: show each employee with department average, each order with customer total, each sale with running total. Aggregates collapse to summaries.
Sales Performance Analysis
Show each salesperson with their sales and team average for performance review
Sales Performance Analysis
SELECT employee_name, sales, AVG(sales) OVER (PARTITION BY team) AS team_avg FROM sales_data;
Managers review individual performance in context of team average. Window function preserves detail needed for individual feedback.
All