Instagram
youtube
Facebook
Twitter

Find Customers Who Haven’t Placed Any Orders

Find Customers Who Haven’t Placed Any Orders

customers Table:

Order Table:

Query Explanation:
SELECT * FROM Customers – Retrieves all the customer records.
WHERE CustomerID NOT IN (SELECT CustomerID FROM Orders) – Filters the list to exclude those customers who have a matching entry in the Orders table, effectively showing only those who haven’t placed any orders.

 

SQL Query:

USE SalesInventoryDB;

select *from customers
where CustomerID not in (select orders.CustomerID from orders); 

 

Output: