题目链接: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 | 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 |
+———–+

思路:
left或right join,选择customerid为空的就是没有进行过交易的。

算法:

select Name from Customers c left outer join Orders o on o.CustomerId=c.Id where o.CustomerId is null

【Leetcode】Customers Who Never Order相关推荐

  1. 【leetcode】86. Partition List

    题目如下: Given a linked list and a value x, partition it such that all nodes less than x come before no ...

  2. 【leetcode】109. Convert Sorted List to Binary Search Tree

    题目如下: Given a singly linked list where elements are sorted in ascending order, convert it to a heigh ...

  3. 【LeetCode】863. All Nodes Distance K in Binary Tree 解题报告(Python)

    [LeetCode]863. All Nodes Distance K in Binary Tree 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http ...

  4. 【Leetcode】100. 相同的树

    题目 给定两个二叉树,编写一个函数来检验它们是否相同. 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的. 示例 1: 输入: 1 1/ \ / \2 3 2 3[1,2,3], [1 ...

  5. 【leetcode】85. Maximal Rectangle 0/1矩阵的最大全1子矩阵

    1. 题目 Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1 ...

  6. 【leetcode】486. Predict the Winner

    题目如下: Given an array of scores that are non-negative integers. Player 1 picks one of the numbers fro ...

  7. 【leetcode】132. Palindrome Partitioning II

    题目如下: 解题思路:本题是[leetcode]131. Palindrome Partitioning的升级版,要求的是求出最小cuts,如果用[leetcode]131. Palindrome P ...

  8. 【Leetcode】103. 二叉树的锯齿形层次遍历

    题目 给定一个二叉树,返回其节点值的锯齿形层次遍历.(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行). 例如: 给定二叉树 [3,9,20,null,null,15,7], 3 ...

  9. 【Leetcode】79.单词搜索

    题目 给定一个二维网格和一个单词,找出该单词是否存在于网格中. 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中"相邻"单元格是那些水平相邻或垂直相邻的单元格.同一个单元格 ...

最新文章

  1. 「赠书」贾扬清推荐,国内首本数据竞赛图书
  2. docker基础介绍
  3. linux 后台运行_Linux系统后台运行应用三板斧
  4. 【ArcGIS|空间分析】数据交互(Google Earth与ArcGIS,ENVI与ArcGIS)
  5. Power Apps相关介绍
  6. 计算机类sci中接受综述么,sci综述类期刊有哪些
  7. 加权平均值不等式的证明
  8. 南阳oj 题目10 skiing
  9. c# 枚举的定义,枚举的用法,获取枚举值
  10. PuTTY 远程连接 Linux 服务器
  11. 数据库中查询经纬度距离远近
  12. 小说阅读网html+css+JavaScript
  13. gcc参数-Wl,–gc-sections,不链接未用函数,减小可执行文件大小
  14. 通过C#生成支付宝收款码 三(支付宝官方SDK配合沙箱调试扫条码支付)
  15. 你想要的继承知识点都在这里
  16. C++STL的发展历程
  17. ruby 实现 bing 的 geocode
  18. X-former:不止一面,你想要的Transformer这里都有
  19. 宝塔面板上行下行,总发送总接收是什么意思?
  20. 51单片机+L298驱动步进电机+L297测速+LCD1602显示+按键调试+Proteus仿真

热门文章

  1. 空气质量(air quality) 简称:AQI 计算AQI等笔记
  2. 4.7 合成复用原则
  3. 论文阅读:Regularizing Deep Networks with Semantic Data Augmentation
  4. 【无标题】我们的三周年————致我的小宝贝
  5. 应用程序无法运行,不是有效的Win32位程序解决(新手向)
  6. Convolution Arithmetic
  7. 浅谈ES6后的TDZ时间死区
  8. 北京博物馆十大镇馆之宝
  9. 微信抢抢票服务器,已有多人被坑!抢票“加速包”慎用!
  10. 阿里云虚拟机Windows系统控制台解压缩文件提示操作异常、解压缩失败的解决方案