Step 7: make and Analyze Query for Year-to-Date Sales by SalesPerson
Management has asked for a
list of total year-to-date sales by each salesperson, with the salesperson having the highest dollar sales at the top. Each salesperson should be identified by his or her business entity ID, first name, and last name. You will make query to display this summary and analyze the results.
a. In the Object Explorer pane, scroll down in the list of tables under the AdventureWorks database until you see the Sales.SalesPerson table. Expand Sales.SalesPerson, and then under that, expand the Columns folder to see the list of columns in this table. You will refer to this list in composing your query.
b. You may also need to refer to the column list for the Person.Person table to get the first and last names.
c. Highlight and delete the code for your previous query, OR press Ctrl + N or click the New Query button to open a new query tab. Ensure that the AdventureWorks2008R2 database is still selected in the drop-down list at the upper left of the window.
d. Referring to the list of columns, enter the SQL code for the desired query in the New Query pane on the right. Your query should display the BusinessEntityID, salesperson FirstName and LastName (from the Person.Person table), and SalesYTD, grouped by BusinessEntityID, FirstName, and LastName, and sorted so that the highest SalesYTD appears at the top. Refer to the query in the previous step for an example of the SQL code for a similar query.
e. Click the ! Execute button on the toolbar to execute this query. Results will be displayed at the bottom of the Query window.
f. Capture a screenshot showing both your SQL code in the upper pane and the query results in the lower pane. (On a Windows computer, to capture a screenshot of the active window, press Alt + PrintScreen, or use the Windows Snipping Tool.)
g. In your Word document, enter the heading "Year-to-Date Sales by Salesperson." Paste your query screenshot into your Microsoft Word document below this heading.
Recently Asked Questions
- The question is about various lectures that are available for students at a conference. Each lecture addresses a topic, is presented by a lecturer. There are a
- This question is based on the View Ridge Gallery database you have been using in the labs. See the textbook for background to the case and the table
- What is Dates and Times data types? What are the implementation problems of Dates and Times data types? Discuss solutions for these problems.