DataBase -- Customers Who Never Order
Question:
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 |
+-----------+
Analysis:
写一个SQL语句,找出没有被order的顾客。
Answer:
select Name from Customers
where Id not in
(select CustomerId from Orders);
DataBase -- Customers Who Never Order的更多相关文章
- LeeCode(Database)-Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- [LeetCode] Customers Who Never Order 从未下单订购的顾客
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- [SQL]LeetCode183. 从不订购的客户 | Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- 【SQL】183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- LeetCode - Customers Who Never Order
Description: Suppose that a website contains two tables, the Customers table and the Orders table. W ...
- 183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- LeetCode——Customers Who Never Order(灵活使用NOT IN以及IN)
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- 分别针对Customers表与Order表的通用查询操作
1.针对customers表通用的查询操作 CustomerForQuery package com.aff.PreparedStatement; import java.lang.reflect.F ...
随机推荐
- ubuntu系统快速搭建开发环境
1.免密登陆 1.1 原理 ssh协议中用到了对称加密和非对称加密,如果不了解可以百度一下,原理引用一下这篇博客 在ssh中,非对称加密被用来在会话初始化阶段为通信双方进行会话密钥的协商.由于非对称加 ...
- YII2.0 用GII创建视图文件后访问404
使用GII的CRUD Generator创建searchModelClass 和控制器类文件,视图文件后,访问控制器地址后出现404的情况. 创建过程如图所示 后来发现是控制器类 Controller ...
- 双击 ajax修改单元格里的值
最终效果 列表页面表格里双击排序修改其值 按钮样式要引入bootstrap才可以用 本文件用的是laravel框架环境 larave路由里 Route::get('category/changesta ...
- python中string,time,datetime三者之间的转化
这里time特指import time中的对象,datetime 特指from datetime import datetime中的对象,string指python自带的字符数据类型. 从使用的情况来 ...
- 怎么修复网站漏洞 骑士cms的漏洞修复方案
骑士CMS是国内公司开发的一套开源人才网站系统,使用PHP语言开发以及mysql数据库的架构,2019年1月份被某安全组织检测出漏洞,目前最新版本4.2存在高危网站漏洞,通杀SQL注入漏洞,利用该网站 ...
- Makefile中wildcard的介绍
在Makefile规则中,通配符会被自动展开.但在变量的定义和函数引用时,通配符将失效.这种情况下如果需要通配符有效,就需要使用函数“wildcard”,它的用法是:$(wildcard PATTER ...
- Python自动化运维——系统性能信息模块
Infi-chu: http://www.cnblogs.com/Infi-chu/ 模块:psutil psutil是一个跨平台库,可以很轻松的为我们实现获取系统运行的进程和资源利用率等信息. 功能 ...
- go学习笔记-程序测试
程序测试 测试是一个可重复的过程,它验证某个东西是否按预期工作.一般通过 go test 进行测试,步骤如下 首先,是我们的文件名.Go 要求所有的测试都在以 _test.go 结尾的文件中.这使得我 ...
- Django学习之天气调查实例(1):工程的开始
开始学习Django,一步一个脚印的进行.思考再三,还是以一个实例来开始学习.手里面正好有几万条单位天气传感器收集的数据,想做一个网页版的天气统计查询之类的小应用,也可以给学生体验,方便教学的进行(尽 ...
- CDH-5.9.2整合spark2
1.编写目的:由于cdh-5.9.2自带spark版本是spark1.6,现需要测试spark2新特性,需要整合spark2, 且spark1.x和spark2.x可以同时存在于cdh中,无需先删除s ...