Customers Who Never Order LeetCode Solution

Last updated on January 21st, 2025 at 10:59 pm

Here, we see the Customers Who Never Order LeetCode Solution. This Leetcode problem is solved using MySQL and Pandas.

List of all LeetCode Solution

Level of Question

Easy

Customers Who Never Order LeetCode Solution

Customers Who Never Order LeetCode Solution

1. Problem Statement

Column NameType
id int
namevarchar
Table: Customers

id is the primary key (column with unique values) for this table. Each row of this table indicates the ID and name of a customer.

Column NameType
idint
customerIdint
Table: Orders

id is the primary key (column with unique values) for this table. customerId is a foreign key (reference columns) of the ID from the Customers table. Each row of this table indicates the ID of an order and the ID of the customer who ordered it.

Write a solution to find all customers who never order anything.

Return the result table in any order.

The result format is in the following example.

Example 1:
Input:

id name
1Joe
2Henry
3Sam
4Max
Customers table:
idcustomerId
13
21
Orders table:

Output:

Customers
Henry
Max

2. Code Implementation in Different Languages

2.1 Customers Who Never Order MySQL

select 
  Name as Customers 
from 
  Customers 
where 
  Id not in (
    select 
      CustomerId 
    from 
      Orders
  );
Scroll to Top