Skip to content

Commit e4bb55c

Browse files
Added Customers Who Never Order
1 parent 2de59a5 commit e4bb55c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Customers Who Never Order
3+
4+
SQL Schema
5+
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.
6+
7+
Table: Customers.
8+
9+
+----+-------+
10+
| Id | Name |
11+
+----+-------+
12+
| 1 | Joe |
13+
| 2 | Henry |
14+
| 3 | Sam |
15+
| 4 | Max |
16+
+----+-------+
17+
Table: Orders.
18+
19+
+----+------------+
20+
| Id | CustomerId |
21+
+----+------------+
22+
| 1 | 3 |
23+
| 2 | 1 |
24+
+----+------------+
25+
Using the above tables as example, return the following:
26+
27+
+-----------+
28+
| Customers |
29+
+-----------+
30+
| Henry |
31+
| Max |
32+
+-----------+
33+
*/
34+
35+
SELECT Customers.Name as Customers
36+
FROM Customers LEFT JOIN Orders ON customers.id = Orders.CustomerId
37+
WHERE Orders.id IS NULL

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ To run a specific problem in your console, go to the file test, add the call to
8484
| [Combine Two Tables](/LeetcodeProblems/Databases/Combine_Two_Tables.sql) | Easy | https://leetcode.com/problems/combine-two-tables |
8585
| [Second Highest Salary](/LeetcodeProblems/Databases/Second_highest_salary.sql)| Easy | https://leetcode.com/problems/second-highest-salary |
8686
| [Nth Highest Salary](/LeetcodeProblems/Databases/nth_Highest_Salary.sql) | Medium | https://leetcode.com/problems/nth-highest-salary |
87-
87+
| [Customers Who Never Order](/LeetcodeProblems/Databases/Customers_Who_Never_Order.sql)| Easy | https://leetcode.com/problems/customers-who-never-order |
8888

8989
### UtilsClasses
9090

0 commit comments

Comments
 (0)