Answered step by step
Verified Expert Solution
Link Copied!

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 $2 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 $2 million should be entered as 2000000. 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

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

Database Systems For Advanced Applications 18th International Conference Dasfaa 2013 Wuhan China April 22 25 2013 Proceedings Part 2 Lncs 7826

Authors: Weiyi Meng ,Ling Feng ,Stephane Bressan ,Werner Winiwarter ,Wei Song

2013th Edition

3642374492, 978-3642374494

More Books

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago