Instagram
youtube
Facebook
Twitter

List Employees Who Processed More Than 2 Orders

List Employees Who Processed More Than 2 Orders

Employees Table:



Orders Table:


Query Explanation:
What this does:

  • JOIN: Combines both tables where the EmployeeID matches.

  • GROUP BY: Groups orders per employee.

  • COUNT(O.OrderID): Counts how many orders each employee processed.

  • HAVING COUNT(O.OrderID) > 2: Filters only those employees who processed more than 2 orders.

  • SELECT: Shows the ID, name, and total order count of those employees.


SQL Query:

SELECT 
    E.EmployeeID,
    E.FirstName,
    E.LastName,
    COUNT(O.OrderID) AS TotalOrders
FROM 
    Employees2 E
JOIN 
    Orders2 O ON E.EmployeeID = O.EmployeeID
GROUP BY 
    E.EmployeeID, E.FirstName, E.LastName
HAVING 
    COUNT(O.OrderID) > 2;


Output: