LeetCode:183.Customers Who Never Order
题目:
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:
思路:NOT IN
用法
SELECT`Name` AS 'Customers'
FROMcustomers
WHEREId NOT IN ( SELECT CustomerId FROM orders )
LeetCode:183.Customers Who Never Order相关推荐
- LeetCode: 183. Customers Who Never Order
LeetCode: 183. Customers Who Never Order 题目描述 Suppose that a website contains two tables, the Custom ...
- leetcode 183. Customers Who Never Order
题意:查找没有点过单的客人 题目链接:https://leetcode.com/problems/customers-who-never-order/ select Name from Custome ...
- Leetcode#183. Customers Who Never Order
题目描述:查找没有预定(orders)的顾客(customers) 普通方法: select Name as Customers from Customers c where c.Id not in ...
- 183. Customers Who Never Order
原题链接:https://leetcode.com/problems/customers-who-never-order/description/ 做完这道题目我才发现,我跟不就不懂 in, exis ...
- 183. Customers Who Never Order没有下过订单的顾客MySQL
假设一个网站包含两个表,Customers表和Orders表.编写SQL查询以查找所有没订购任何商品的客户. customers orders Output 用到left outer join: s ...
- 【Leetcode】Customers Who Never Order
题目链接:https://leetcode.com/problems/customers-who-never-order/ 题目: Suppose that a website contains tw ...
- [SQL]LeetCode183. 从不订购的客户 | Customers Who Never Order
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...
- LeetCode 103. Binary Tree Zigzag Level Order Traversal
LeetCode 103. Binary Tree Zigzag Level Order Traversal Solution1:基于层次遍历的微改 /*** Definition for a bin ...
- LeetCode:汇总区间【228】
LeetCode:汇总区间[228] 题目描述 给定一个无重复元素的有序整数数组,返回数组区间范围的汇总. 示例 1: 输入: [0,1,2,4,5,7] 输出: ["0->2&quo ...
最新文章
- 双系统Ubuntu无法进入Windows磁盘的解决方法
- 华中科技大学计算机科学卓越班,2016年华中科技大学光电信息科学与工程(卓越计划实验班)专业在江苏录取分数线...
- 删除链表最小节点c语言,最简单的链表删除第一个节点时释放内存的问题
- ubuntu18.04(python3.6)安装pip3报错:ImportError: cannot import name 'sysconfig'
- C和C++的区别 04.函数重载
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级
- 西安电子科技大学计算机接口与通用技术答案,西安电子科技大学--西电《计算机接口与通信技术》平时作业...
- maven 之 setting.xm 的配置详解、说明
- 【动画技巧】GIF动画转SWF小技巧
- [Erlang危机](4.4)命名管道
- 【网络信息安全】授权与访问控制
- SpringAOP导致@Autowired依赖注入失败
- matlab中三维非线性拟合,matlab非线性拟合与绘制三维曲面
- 【Matlab故障诊断分析】BP神经网络三相逆变器故障诊断研究【含源码 1736期】
- 微信小程序 input隐藏和不可操作的设置
- 无法加入域,隶属于域,工作组选项为灰色
- 一问解决设备管理器里面提示:未知usb设备(设备描述符请求失败) 或者是“Unknown USB Device(Device Descriptor Request Sailed)”错误
- swift方法顺序 不成文规定
- 茜茜:大二开始布局学习大数据,结果如何?
- Lucene.net和盘古分词使用小结