[LeetCode] 183. Customers Who Never Order_Easy tag: SQL
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 |
+-----------+
Code
SELECT Name AS Customers FROM Customers AS c WHERE c.Id NOT IN (SELECT CustomerId FROM Orders)
[LeetCode] 183. Customers Who Never Order_Easy tag: SQL的更多相关文章
- LeetCode 183. Customers Who Never Order (从不订购的客户)
题目标签: 题目给了我们 Customers 和 Orders 两个表格,让我们找到 从没订购过的客户. 首先从Orders 得到 订购过的CustomerId,然后再去Customers 里找 没有 ...
- leetcode 183. Customers Who Never Order
select Name as Customers from Customers where Id not in (select CustomerId from Orders);
- 【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] 619. Biggest Single Number_Easy tag: SQL
Table number contains many numbers in column num including duplicated ones.Can you write a SQL query ...
- [LeetCode] 584. Find Customer Referee_Easy tag: SQL
Given a table customer holding customers information and the referee. +------+------+-----------+ | ...
- [LeetCode] 620. Not Boring Movies_Easy tag: SQL
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...
- [LeetCode] 181. Employees Earning More Than Their Managers_Easy tag: SQL
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
- [LeetCode] 176. Second Highest Salary_Easy tag: SQL
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- [LeetCode] 182. Duplicate Emails_Easy tag: SQL
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
随机推荐
- SQL Server Profiler工具【转】
一.SQL Profiler工具简介 转自:http://www.cnblogs.com/kissdodog/p/3398523.html SQL Profiler是一个图形界面和一组系统存储过程,其 ...
- 原生js--事件类型
1.表单事件: submit事件 reset事件 click事件 change事件 focus事件(不冒泡) (IE和ES5支持冒泡的focusin) blur事件(不冒泡) (IE和ES5支持冒泡的 ...
- linux ntp时间服务器配置
Network Time Protocol (NTP) 也是RHCE新增的考试要求. 学习的时候也顺便复习了一下如何设置Linux的时间,现在拿出来和大家分享 设置NTP服务器不难但是NTP本身是一个 ...
- myisam与innodb索引比较
MyISAM支持全文索引(FULLTEXT).压缩索引,InnoDB不支持 InnoDB支持事务,MyISAM不支持 MyISAM顺序储存数据,索引叶子节点保存对应数据行地址,辅助索引很主键索引相差无 ...
- AutoMapper queryable extensions 只找需要的字段
http://jahav.com/blog/automapper-queryable-extensions/ How to generate a LINQ query for your DTOs Au ...
- thinkCMF----使用自定义函数
thinkCMF使用自定义函数:app 下新建 common.php
- Mysql: mysqlbinlog命令查看日志文件
想查看mysql的binlog文件,但是裸的binlog文件是无法直视的,mysqlbinlog这个工具是用来查看binlog文件内容的(使用方式man mysqlbinlog查看),但是使用mysq ...
- POJ-2329 Nearest number - 2(BFS)
Nearest number - 2 Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4100 Accepted: 1275 De ...
- 10W年薪和30W+年薪的产品经理差距在哪?
举办到今年第六届壹佰案例峰会,认识的“程序猿/媛”朋友越来越多,时间长了就发现,程序员的世界一点也不单调,外界传说的不善言辞.最大的乐趣就是买“机械键盘”都是不对的.你见过周末组团去山里骑哈雷的研发经 ...
- Python3.6.3中,functools似乎不能用
用pip install安装时报编码错误: return s.decode(sys.__stdout__.encoding) UnicodeDecodeError: 'utf-8' codec can ...