The business question that can only be answered in SQL using a window function, and not through standard GROUP BY aggregation, is: "For every individual sales transaction, retrieve its transaction ID, the customer ID, the transaction amount, and the average transaction amount for that specific customer across all their transactions."
A standard GROUP BY aggregation, such as `SELECT customer_id, AVG(transaction_amount) FROM sales_transactions GROUP BY customer_id;`, would return a single row for each unique customer, showing only their average transaction amount. This approach aggregates, or collapses, all individual transaction details for a customer into one summary row, thereby losing the visibility of each unique transaction ID and its specific amount. The problem asks to see the individual transaction details *alongsidethe customer's overall average. This is where standard GROUP BY fails because it fundamentally alters the row str....
Log in to view the answer