Question
Query 1 : Write a SELECT statement that uses an aggregate window function to get the total amount of each order. Return these columns: The
Query 1: Write a SELECT statement that uses an aggregate window function to get the total amount of each order. Return these columns:
The order_id column from the order_instruments table
The total amount for each order item in the order_instruments table (Hint: You can calculate the total amount by subtracting the discount amount from the item price and then multiplying it by the quantity)
The total amount for each order
Sort the result set in ascending sequence by the order_id column.
Query 2: Modify the solution to the above query 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.
Database Schema: ------------------------------ Tables: musicians, orders, order_instruments, instruments Table columns ----------------------- musicians: musician_id, email_address, password, first_name, last_name, shipping_address_id, billing_address_id orders: order_id, musician_id, order_date, ship_amount, tax_amount, ship_date, ship_address_id, card_type, card_number, card_expires, billing_address_id order_instruments: item_id, order_id, instrument_id, item_price, discount_amount, quantity
instruments: instrument_id, category_id, instrument_code, instrument_name, description, list_price, discount_percent, date_added
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started