Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topic 6 Query included at the bottom. Please assist as much as possible. Details: The purpose of this assignment is to update a previous query

Topic 6 Query included at the bottom.

Please assist as much as possible.

Details:

The purpose of this assignment is to update a previous query and present it in an easily readable format.

For this assignment, continue to assume the role of a data analyst at Adventure Works Cycles Company.

Part 1

Using what you have learned, replicate the data found in #MySalesOrderDetailbyDate and #MyProductPriceHistory using a single line of SQL code. Using the query completed in the Topic 6 assignment, modify the query and present it in an easy-to-read format. To do this, write the query in two single statements without temporary tables, using abbreviations and line spacing.

Please note that when SQL queries are run, results are generated in the form of data. This data should be exported and saved to Excel for a visual check of accuracy.

Create a Word document that includes the SQL query code.

Part 2

Karen Berge, a Document Control Assistant at the company, comes to you with a request. Karen wants the titles and file names of all of the documents she has produced and has asked you to generate this information for her. Using what you have learned, produce a query in one statement to give her the information she needs. Note that constructing the query will require some thinking outside the box since the relationships are not well documented.

Please note that when SQL queries are run, results are generated in the form of data. This data should be exported and saved to Excel for a visual check of accuracy. This Excel file should include the names of all documents Karen has produced.

Add to the Word document you created in Part 1 and include the SQL query code associated with the query you wrote to locate Karen's documents.

Select *

From MyProduct;

Select*

From MyPriceHistory;

Select MP.ProductID, MP.Name, MP.ListPrice, MPH.EndDate

Into #MyProductPriceHistory

From MyProduct As MP

Inner Join MyPriceHistory AS MPH

On MP.ListPrice=MPH.ListPrice;

Select*From #MyProductPriceHistory

Where EndDate IS NOT NULL;

Question 2

Select*

From MyProduct

Select*

From [Sales].[SalesOrderDetail];

Select MP.ProductID, MP.Name, SO.SalesOrdeID, SO.OrderQty

Into #MySalesHistory

From MyProduct AS MP

Inner JOin [Sales].[SalesOrderDetail] AS So

ON MP.ProductID = SO.ProductID;

Select*

From #MySalesHistory

Question 3

Select SOD.ProductID, SOH.OrderDate

Into #MyTemp

From AS SOD

Inner Join [Sales].[SalesOrderHeader] AS SOH

ON SOD.SalesOrderID=SOH.SalesOrderID;

Select MP.Name, SOD.OrderQty, MP.ProductID

INTO #MySalesHistory

From MyProduct AS MP

Inner Joins [Sales].[SalesOrderDetail] AS SOD

ON MP.ProductID=SOD.ProductID;

Select MT.ProductID, MT.OrderDate, MSH.Name, MSH.OrderQty

From #MyTemp as MT

Inner JOin #MySalesHistory AS MSH

On MT.ProductID=MSH.ProductID

Order BY OrderDate ASC;

Select Sum(OrderQty) AS "Quantity Sum"

From #MySalesHistory

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_2

Step: 3

blur-text-image_3

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 And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

Determining how many people will lose their jobs.

Answered: 1 week ago