Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Display number of orders handled by each employee for each year. First, use a CTE to hold employee Id , order Id , and the
Display number of orders handled by each employee for each year.
First, use a CTE to hold employee Id order Id and the year the order was handled. Next, from the CTE
select employee Id year, and count number of orders in that year.
SQL Example Statement
WITH EmployeeSales EmployeeId EmployeName, OrderId, OrderYear AS
SELECT E EmployeeId, E FirstName LastName, OOrderId, YEAR O OrderDate
FROM HR Employees AS E JOIN Sales. Orders AS
ON EEmployeeId O EmployeeId
SELECT EmployeeId, EmployeName, COUNTOrderId AS "Number of Orders", OrderYear
FROM EmployeeSales
GROUP BY EmployeeId, EmployeName, OrderYear
ORDER BY OrderYear;
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