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 ...
随机推荐
- 使用公共的存储过程实现repeater的分页
当一个项目repeater分页多的时候使用公共的存储过程实现分页,是不错的选择 ALTER PROC [dbo].[P_Common_proc] -- 通用分页存储过程 @TableName varc ...
- php GD图片四角圆形处理
<?php /** * blog:http://www.zhaokeli.com * 处理四角圆图片 * @param string $imgpath 源图片路径 * @param intege ...
- 首层nginx 传递 二级代理,三级代理......多级代理nginx 客户端真实IP的方法
首层nginx(172.25.10.1):先获取真实IP($remote_addr),再将真实IP传递给X-Forwarded-For proxy_set_header X-Real-IP $r ...
- mysql新增和更新表从已有数据库里面获取的sql语句
在mysql数据库从已有数据库表插入数据到另一表的sql例子 insert into c(`name`) select name from b; 在mysql数据库从已有数据库表更新数据到另一表的sq ...
- sbt打包error(sbt.librarymanagement.ResolveException: unresolved dependency: org.apache.spark#spark-streaming;2.3.1: not found)
解决方法: 修改simple.sbt文件: cd /usr/local/spark/myapp/TestStream vim simple.sbt 切记:中间相连部分两个百分号一定要写上
- queue消息队列
class queue.Queue(maxsize=0) #先入先出 class queue.LifoQueue(maxsize=0) #last in fisrt out class queue. ...
- 转:python教程专题资源免费下载整理合集收藏
python教程专题资源免费下载整理合集收藏 < Python学习手册(第4版)>(Learning Python, 4th Edition)[PDF] 94MB 简体中文 <Pyt ...
- idea 普通文件夹 转换成 module
经常会遇到从GitHub上download的progect在idea里面打开是普通文件夹形式,而并不是我们想要的module形式(文件夹图标右下角有个蓝色的tag),那么如何快速转换成我们想要的mod ...
- JSON初体验(二):Gson解析
今天,我们来介绍一下Gson的jar包的用法. JSON解析之Gson 特点:编码简介,谷歌官方推荐 数据之间的转换: 1.将json格式的字符串{}转换成为java对象 API: <T> ...
- 25、react入门教程
0. React介绍 0.1 什么是React? React(有时称为React.js 或ReactJS)是一个为数据提供渲染HTML视图的开源JavaScript库. 它由FaceBook.Inst ...