Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 create a query to display this summary and analyze the results.
- 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.
- You may also need to refer to the column list for the Person.Person table to get the first and last names.
- 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.
- 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.
- Click the ! Execute button on the toolbar to execute this query. Results will be displayed at the bottom of the Query window.
- what is the correct SQL code for this? not getting results from : SELECT BusinessEntityID,FirstName,LastName, sum(SalesYTD) as Sum_of_SalesYTD
FROM Person.Person
JOIN Sales.SalesPerson P ON S.ProductID= P.ProductID
GROUP BY BusinessEntityID,FirstName,LastName
ORDER BY Sum_of_SalesYTD DESC;
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