Modify the solution SELECT roi.order_id, SUM((roi.item_price - roi.discount_amount) * roi.quantity) AS item_amoumt, SUM((roi.item_price - roi.discount_amount) * roi.quantity)
Fantastic news! We've Found the answer you've been seeking!
Question:
Modify the solution
SELECT
roi.order_id,
SUM((roi.item_price - roi.discount_amount) * roi.quantity) AS item_amoumt,
SUM((roi.item_price - roi.discount_amount) * roi.quantity) OVER (PARTITION BY roi.order_id) AS order_amount
FROM
readers_order_items roi
GROUP BY
roi.order_id, roi.item_id
ORDER BY
roi.order_id ASC;
so the column that contains the total amount for each order contains a cumulative total by item amount.
Add another column to the SELECT statement that uses an aggregate window function to get the
average item amount for each order.
Modify the SELECT
statement so it uses a
named window for
the two aggregate
functions.
Related Book For
Posted Date: