Customers Who Never Order - Sql - Easy - LeetCode
💻 coding

Customers Who Never Order - Sql - Easy - LeetCode

1 min read 117 words
1 min read
ShareWhatsAppPost on X
  • 1The article explains how to identify customers who have never placed an order using SQL.
  • 2It provides an example with two tables: Customers and Orders.
  • 3The SQL query uses a subquery to filter out customers with no orders.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"The article explains how to identify customers who have never placed an order using SQL."

Customers Who Never Order - Sql - Easy - LeetCode

Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.

Table: Customers.

+----+-------+ | Id | Name | +----+-------+ | 1 | Joe | | 2 | Henry | | 3 | Sam | | 4 | Max | +----+-------+ Table: Orders.

+----+------------+ | Id | CustomerId | +----+------------+ | 1 | 3 | | 2 | 1 | +----+------------+ Using the above tables as example, return the following:

+-----------+ | Customers | +-----------+ | Henry | | Max | +-----------+

# Write your MySQL query statement below
Select Name as Customers from Customers Where Id Not In(select CustomerId from Orders);

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

sumitc91

Published on 16 October 2020 · 1 min read · 117 words

Part of AskGif Blog · coding

You might also like