SQL users: The QUALIFY clause is pure syntactic sugar
https://modern-sql.com/caniuse/qualify
Using a window function, we could add in a new column total_order_amount which represents the total order amount per customer. We could simply write:
SELECT
date,
customer,
order_amount,
SUM(order_amount) OVER(PARTITION BY customer) AS total_order_amount
FROM orders
ORDER BY date
the window function SUM(order_amount) OVER(PARTITION BY customer) effectively partitioned our table into different “windows” (one for each customer) and then calculated the total_order_amount for each of these windows. All of this was achieved without using a GROUP BY aggregation, allowing us to retain the same number of rows.
April 11, 2023 at 10:23:40 AM EDT
*
FILLER