Skip to content

Commit

Permalink
Update and rename 0183. Customers Who Never Order.sql to 0183.(Easy) …
Browse files Browse the repository at this point in the history
…Customers Who Never Order.sql
  • Loading branch information
haibarawu authored Jun 4, 2020
1 parent 5f0a814 commit d74f50e
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
/****************************************
183. Customers Who Never Order
183. 从不订购的客户
Difficulty: Easy
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.
某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。
SQL Schema:
Create table If Not Exists Customers (Id int, Name varchar(255))
Create table If Not Exists Orders (Id int, CustomerId int)
Truncate table Customers
insert into Customers (Id, Name) values ('1', 'Joe')
insert into Customers (Id, Name) values ('2', 'Henry')
insert into Customers (Id, Name) values ('3', 'Sam')
insert into Customers (Id, Name) values ('4', 'Max')
Truncate table Orders
insert into Orders (Id, CustomerId) values ('1', '3')
insert into Orders (Id, CustomerId) values ('2', '1')
Table: Customers.
+----+-------+
Expand All @@ -25,6 +39,7 @@ Table: Orders.
+----+------------+
Using the above tables as example, return the following:
例如给定上述表格,你的查询应返回:
+-----------+
| Customers |
+-----------+
Expand All @@ -50,3 +65,4 @@ WHERE Customers.Id NOT IN (
FROM Orders
)


0 comments on commit d74f50e

Please sign in to comment.