Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Enter a SQL SELECT command that displays the following from the Sales.SalesOrderDetails table: ProductID and sum of LineTotal. Use an aggregate function for the sum.
Enter a SQL SELECT command that displays the following from the Sales.SalesOrderDetails table: ProductID and sum of LineTotal. Use an aggregate function for the sum. Assign an appropriate column heading such as TotalSales to the sum. Include a clause that will group results based on ProductID. Include a clause that will limit the displayed results to those having a sum of LineTotal greater than $ million. Include a clause that will sort the results in descending order by the sum or LineTotal, so the product with the highest sales will be displayed first.
NOTE: In SQL numeric values should be entered using only digits and if necessary the decimal point. Do not use commas, the dollar sign, or any other currency symbol. The figure $ million should be entered as Be sure to count the number of zeros correctly.Select and copy the text of your SQL command for best
selling products written in the previous step.
Open a new blank query pane and paste the best
selling products SQL command into this pane. Execute the query to make sure it still works.
Modify the FROM clause of the query to join the Sales.SalesOrderDetail table to the Production.Product table, using the ProductID column in both tables for the join.
Modify the SELECT clause of the query to display the Name column
from the Production.Product table
after the ProductID column in the query results.
Modify the GROUP BY clause of the query to group by both ProductID and Name.
This is necessary because columns can only appear in the SELECT clause of a grouped query if they also appear in the GROUP BY column, or if they are used in an aggregate function.
Wherever the ProductID column appears in the query, ensure that it is fully qualified, that is
that it has the name of the appropriate table and a period in front of it
that is
either SalesOrderDetail.ProductID or Product.ProductID
This is necessary because there is a ProductID column in both tables and you must tell SQL which one you mean in each case.
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