183. Customers Who Never Order
来源:互联网 发布:解数学题用什么软件 编辑:程序博客网 时间:2024/06/01 08:02
DescriptionHintsSubmissionsDiscussSolution
SQL Schema Discuss Pick One
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 |
+———–+
Answer:
SELECT c.Name AS Customers FROM Customers cWHERE c.Id NOT IN (SELECT CustomerId FROM Orders)SELECT c.Name Customers FROM Customers c LEFT JOIN Orders oON c.Id = o.CustomerId WHERE o.CustomerId IS NULL
阅读全文
0 0
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- 183. Customers Who Never Order
- Customers Who Never Order
- Customers Who Never Order
- Customers Who Never Order
- Customers Who Never Order
- Customers Who Never Order
- LEETCODE database 183. Customers Who Never Order
- leetcode 183. Customers Who Never Order
- leetcode.183. Customers Who Never Order
- 【leetcode Database】183. Customers Who Never Order
- leetcode 183. Customers Who Never Order
- Angular4学习笔记(四)- 依赖注入
- JavaScript 数组
- Semi-supervised Segmentation of Optic Cup in Retinal Fundus
- 数字信号处理学习:基于CIC滤波器的正交检波
- FFMPEG录屏软件开发之YUV AAC合成MP4
- 183. Customers Who Never Order
- 集合类(一)
- python 关于集合,还有浅拷贝和深拷贝的问题
- 腾讯云赋能“互联网+”,中国制造业迎智能化新机遇
- 微信发大招:公众号群发文章支持添加小程序
- Socket 编程
- lua学习笔记(1)
- 【水比赛】中国高校计算机大赛
- 独家 | 科大讯飞陶晓东:讯飞在人工智能+智慧医疗领域未来会做的3件事