Answered step by step
Verified Expert Solution
Link Copied!

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 3.1 Statement
WITH EmployeeSales (EmployeeId, EmployeName, OrderId, OrderYear) AS
SELECT E. EmployeeId, E. FirstName +''+ LastName, O.OrderId, YEAR (O. OrderDate)
FROM HR. Employees AS E JOIN Sales. Orders AS 0
ON E.EmployeeId = O. EmployeeId
SELECT EmployeeId, EmployeName, COUNT(OrderId) AS "Number of Orders", OrderYear
FROM EmployeeSales
GROUP BY EmployeeId, EmployeName, OrderYear
ORDER BY OrderYear;
image text in transcribed

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

Step: 3

blur-text-image

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago