Welcome Back

Google icon Sign in with Google
OR
I agree to abide by Pharmadaily Terms of Service and its Privacy Policy

Create Account

Google icon Sign up with Google
OR
By signing up, you agree to our Terms of Service and Privacy Policy
Instagram
youtube
Facebook

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: