Question
A MySQL query that gets the list of products sold and the total sales amount for each category could be: a select distinct a.CategoryID, a.CategoryName,
A MySQL query that gets the list of products sold and the total sales amount for each category could be:
a | select distinct a.CategoryID, a.CategoryName, b.ProductName, sum(c.ExtendedPrice) as ProductSales from Categories a inner join Products b on a.CategoryID = b.CategoryID inner join ( select distinct y.OrderID, y.ProductID, x.ProductName, y.UnitPrice, y.Quantity, y.Discount, round(y.UnitPrice * y.Quantity * 1 - y.Discount, 2) as ExtendedPrice from Products x inner join Order_Details y on x.ProductID = y.ProductID order by y.OrderID |
b | select distinct a.CategoryID, a.CategoryName, b.ProductName, sum(c.ExtendedPrice) as ProductSales from Categories a inner join Products b on a.CategoryID = b.CategoryID inner join ( select distinct y.OrderID, y.ProductID, x.ProductName, y.UnitPrice, y.Quantity, y.Discount, round(y.UnitPrice * y.Quantity * (1 - y.Discount), 2) as ExtendedPrice from Products x inner join Order_Details y on x.ProductID = y.ProductID order by y.OrderID ) c on c.ProductID = b.ProductID inner join Orders d on d.OrderID = c.OrderID where d.OrderDate between date('1997/1/1') and date('1997/12/31') group by a.CategoryID , a.CategoryName , b.ProductName order by a.CategoryName , b.ProductName , ProductSales; |
c | select a.CategoryID, a.CategoryName, b.ProductName, sum(c.ExtendedPrice) as ProductSales from Categories a inner join Products b on a.CategoryID = b.CategoryID inner join ( select distinct y.OrderID, y.ProductID, x.ProductName, y.UnitPrice, y.Quantity, y.Discount, round(y.UnitPrice * y.Quantity * (1 - y.Discount), 2) as ExtendedPrice from Products x inner join Order_Details y on x.ProductID = y.ProductID order by y.OrderID ) c on c.ProductID = b.ProductID inner join Orders d on d.OrderID = c.OrderID where d.OrderDate between date('1997/1/1') and date('1997/12/31') group by a.CategoryID , a.CategoryName , b.ProductName order by a.CategoryName , b.ProductName , ProductSales; |
d | select distinct a.CategoryID, a.CategoryName, b.ProductName, sum(c.ExtendedPrice) as ProductSales from Categories a inner join Products b on a.CategoryID = b.CategoryID inner join ( select distinct y.OrderID, y.ProductID, x.ProductName, y.UnitPrice, y.Quantity, y.Discount, round(y.UnitPrice * y.Quantity * (1 - y.Discount), 2) as ExtendedPrice from Products x inner join Order_Details y on x.ProductID = y.ProductID order by y.OrderID ) on c.ProductID = b.ProductID inner join Orders d on d.OrderID = c.OrderID where d.OrderDate between date('1997/1/1') and date('1997/12/31') group by a.CategoryID , a.CategoryName , b.ProductName order by a.CategoryName , b.ProductName , ProductSales; |
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