Question
Write a SELECT statement that answers this question: What is the total quantity purchased for each instrument within each category? Return these columns: The category_name
- Write a SELECT statement that answers this question: What is the total quantity purchased for each instrument within each category? Return these columns:
The category_name column from the category table
The instrument_name column from the instruments table
The total quantity purchased for each instrument with orders in the order_instruments table
Use the WITH ROLLUP operator to include rows that give a summary for each category name as well as a row that gives the grand total. Use the IF and GROUPING functions to replace null values in the category_name and instrument_name columns with literal values if theyre for summary rows.
Database Schema: ------------------------------ Tables: musicians, orders, order_instruments, instruments, categories 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
categories: category_id, category_name
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