Instagram
youtube
Facebook
Twitter

Find Employees Who Have Not Processed Any Orders in SQL

Find Employees Who Have Not Processed Any Orders in SQL


Employees Table:

 

 

orders Table:

Query Explanation:

SELECT *
 Retrieves all columns from the Employees table.

FROM Employees
 Specifies that data should be selected from the Employees table.

WHERE EmployeeID NOT IN (...)
 Filters the employees by excluding those whose EmployeeID exists in the Orders table.

SELECT DISTINCT EmployeeID FROM Orders
 Fetches all unique employee IDs who have processed at least one order.

This query helps identify employees who haven't processed any orders yet.

 

SQL Query:

USE SalesInventoryDB;
 
select * from Employees
where EmployeeID not in (select  orders.EmployeeID from orders);

 

Output: