[LeetCode][SQL]Customers Who Never Order

https://leetcode.com/problems/customers-who-never-order/

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       |
+-----------+

好久没写SQL一下子忘记is null这个东西了,= null并没有用。
select Name as Customers from Customers left join Orders on Customers.Id = Orders.CustomerId where CustomerId is null
时间: 2024-10-13 11:54:48

[LeetCode][SQL]Customers Who Never Order的相关文章

【Leetcode】Customers Who Never Order

题目链接:https://leetcode.com/problems/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

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 |

LeetCode 183. Customers Who Never Order (从不订购的客户)

题目标签: 题目给了我们 Customers 和 Orders 两个表格,让我们找到 从没订购过的客户. 首先从Orders 得到 订购过的CustomerId,然后再去Customers 里找 没有出现过的 Id,返回名字. Java Solution: Runtime:  264 ms, faster than 53 % Memory Usage: N/A 完成日期:06/01/2019 关键点:NOT IN # Write your MySQL query statement below

【leetcode SQL】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

[LeetCode] 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

LeetCode - Customers Who Never Order

Description: 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 一种比较高效的方法是左连接,左连接之后任然使用被连接的两个表或多个表来定位连接之后的表的数据. # Write your MySQL query statement bel

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 |

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

LINQ to SQL语句(5)之Order By

Order By操作 适用场景:对查询出的语句进行排序,比如按时间排序 等等. 说明:按指定表达式对集合排序:延迟,:按指定表达式对集合 排序:延迟,默认是升序,加上descending表示降序,对应的扩展方法是 OrderBy和OrderByDescending 1.简单形式 这个例子使用 orderby 按雇用日期对雇员进行排序: var q = from e in db.Employees orderby e.HireDate select e; 说明:默认为升序 2.带条件形式 注意:W