Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago