Question
Usethe content ofthe AdventureWorks sampledatabase.Lab 3-1/* Modify the following query to add a column that identifies theperformance of salespersons and contains the following feedbackbased on
Usethe content ofthe AdventureWorks sampledatabase.Lab 3-1/* Modify the following query to add a column that identifies theperformance of salespersons and contains the following feedbackbased on the number of orders processed by a salesperson:'Need to Work Hard' for the order count range 1-100'Fine' for the order count range of 101-300'Strong Performer' for the order count greater than 300Give the new column an alias to make the report more readable. */SELECTSalesPersonID,p.LastName,p.FirstName,COUNT(o.SalesOrderid)[Total Orders]FROMSales.SalesOrderHeader oJOINPerson.Person pONo.SalesPersonID =p.BusinessEntityIDGROUPBYo.SalesPersonID,p.LastName,p.FirstNameORDERBYp.LastName,p.FirstName;Lab 3-2/* Modify the following query to add a rank without gaps in theranking based on total orders in the descending order. Alsopartition by territory.*/SELECTo.TerritoryID,s.Name,year(o.OrderDate)Year,COUNT(o.SalesOrderid)[Total Orders]FROMSales.SalesTerritory s JOINSales.SalesOrderHeader oONs.TerritoryID =o.TerritoryIDGROUPBYo.TerritoryID,s.Name,year(o.OrderDate)ORDERBYo.TerritoryID;Lab 3-3/* Write a query that returns the male salesperson(s) who received the lowest bonus amount in Europe. Include the salesperson'sid and bonus amountin the returned data. Your solution must retrieve the tie if there is a tie. */
Lab 3-4/* Write a query to retrieve the most valuable customer of each year.The most valuable customer of a year is the customer who has made the most purchase for the year. Use the yearly sum of the TotalDue column in SalesOrderHeader as a customer's total purchase for a year. If there is a tie for the most valuable customer, your solution should retrieve it.Include the customer's id, total purchase, and total order count for the year. Display the total purchase in two decimal places.Sort the returned data by the year. */Lab 3-5/* Write a query to retrieve the dates in which there was at least one product sold but no product in red(Color) was sold. Return the "date" and "total product quantity soldfor the date" columns. The order quantity can be found inSalesOrderDetail. Display only the date for a date.Sort the returned data by the"total product quantity sold for the date" column in desc. */
Product (Production 8 ProductID Person (Person) BusinessEntityID Person Type NameStyle Title Employee (HumanR 8 Business EntityID National DNumber LoginID OrganizationNode Organization Level Job Title Sales Person (Sale 8 Business EntityID TerritoryID Sales Quota SalesTerritory (Sales) - TerritoryID Name Country Region Code [Group] Name Bonus FirstName CommissionPct ProductNumber MakeFlag Finished GoodsFlag Color SafetyStockLevel ReorderPoint MiddleName SalesYTD LastName BirthDate SalesLast Year Suffix MaritalStatus EmailPromotion Gender rowguid ModifiedDate Standard Cost AdditionalContactint ListPrice Size Customer (Sales) 2 Customers SalesOrderDetail (S: Sales Orders 8 Sales OrderDetaillD Carrier TrackingNu... OrderQty ProductID SizeUnit MeasureCod. PersonID StorelD EmailAddress (Perso & Business EntityID 8 Email AddressID SalesOrder Header (Sale Sales OrderID WeightUnitMeasure.. Weight DaysToManufacture ProductLine SpecialOfferID TerritoryID Account Numbei MO Revision Number Unit Price UnitPriceDiscount Class rowguid Order Date Email Address rowguid ModifiedDate 00 -- - ::: DueDate ShipDate Line Total rowguid Style ProductSubcategoryl Product (Production 8 ProductID Person (Person) BusinessEntityID Person Type NameStyle Title Employee (HumanR 8 Business EntityID National DNumber LoginID OrganizationNode Organization Level Job Title Sales Person (Sale 8 Business EntityID TerritoryID Sales Quota SalesTerritory (Sales) - TerritoryID Name Country Region Code [Group] Name Bonus FirstName CommissionPct ProductNumber MakeFlag Finished GoodsFlag Color SafetyStockLevel ReorderPoint MiddleName SalesYTD LastName BirthDate SalesLast Year Suffix MaritalStatus EmailPromotion Gender rowguid ModifiedDate Standard Cost AdditionalContactint ListPrice Size Customer (Sales) 2 Customers SalesOrderDetail (S: Sales Orders 8 Sales OrderDetaillD Carrier TrackingNu... OrderQty ProductID SizeUnit MeasureCod. PersonID StorelD EmailAddress (Perso & Business EntityID 8 Email AddressID SalesOrder Header (Sale Sales OrderID WeightUnitMeasure.. Weight DaysToManufacture ProductLine SpecialOfferID TerritoryID Account Numbei MO Revision Number Unit Price UnitPriceDiscount Class rowguid Order Date Email Address rowguid ModifiedDate 00 -- - ::: DueDate ShipDate Line Total rowguid Style ProductSubcategorylStep 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