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

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!