Question
Write a SELECT statement that uses the analytic functions to get the highest and lowest sales by product within each category. Return these columns: The
Write a SELECT statement that uses the analytic functions to get the highest and
lowest sales by product within each category. Return these columns:
The category_name column from the Categories table
The product_name column from the Products table
A column named total_sales that shows the sum of the sales for each
product with sales in theOrder_Items table.
A column named highest_sales that uses the FIRST_VALUE function to
show the name of the product with the highest sales within each category.
A column named lowest_sales that uses the LAST_VALUE function to
show the name of the product with the lowest sales within each category.
This is using the schema below, thanks!
2 Administrators AdminID EmailAddress Password FirstName LastName OrderItems ItemID OrderID Productio ItemPrice DiscountAmount Quantity Addresses AddressID Customer Line! Orders Orderin CustomerID Order Date ShipAmount TexAmount ShipDate ShipAddressID Card Type Card Number CardExpires BillingAddress Line2 City State ZipCode Phone Disabled Products ProductID CategoryID Product Code Product Name Description ListPrice DiscountPercent Date Added 8 Categories CategoryID CategoryName Customers Customer Email Address Password First Name LastName ShippingAddressID BillingAddressIDStep 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