Approach: Using sub-query and NOT IN clause [Accepted]


If we have a list of customers who have ever ordered, it will be easy to know who never ordered.

We can use the following code to get such list.

select customerid from orders;

Then, we can use NOT IN to query the customers who are not in this list.


select as 'Customers'
from customers
where not in
    select customerid from orders