less than 1 minute read

Problem

problem-183

Query

SELECT c.name as Customers
FROM Customers AS c
WHERE c.id NOT IN (
    SELECT customerId
    FROM Orders
)

Editorial Solution

Approach 1: Filtering Data with Exclusion Criteria

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

Approach 2: Left Join on customers

SELECT name AS 'Customers'
FROM Customers
LEFT JOIN Orders ON Customers.Id = Orders.CustomerId
WHERE Orders.CustomerId IS NULL

Tags:

Updated: