博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
183. Customers Who Never Order--solution
阅读量:4598 次
发布时间:2019-06-09

本文共 727 字,大约阅读时间需要 2 分钟。

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

My solution:

SELECT A.Name as Customers from Customers A

LEFT JOIN Orders B on A.Id = B.CustomerId
WHERE B.CustomerId is NULL;

转载于:https://www.cnblogs.com/chenwong/p/8497062.html

你可能感兴趣的文章
maven+testng+reportng的pom设置
查看>>
IT telephone interview
查看>>
gitlab安装配置
查看>>
ps载入画笔
查看>>
悲怆:IT人的一声叹息->一个程序员的自白[转帖]
查看>>
[SpringMVC]自定义注解实现控制器访问次数限制
查看>>
日记(序)
查看>>
A == B ?
查看>>
洛谷P3763 [Tjoi2017]DNA 【后缀数组】
查看>>
GSM模块_STM32实现GPRS与服务器数据传输经验总结
查看>>
5.Python进阶_循环设计
查看>>
【NLP】揭秘马尔可夫模型神秘面纱系列文章(一)
查看>>
Android采访开发——2.通用Android基础笔试题
查看>>
UVa 442 Matrix Chain Multiplication(矩阵链,模拟栈)
查看>>
多种方法求解八数码问题
查看>>
spring mvc ModelAndView向前台传值
查看>>
(黑客游戏)HackTheGame1.21 过关攻略
查看>>
Transparency Tutorial with C# - Part 2
查看>>
android 文件上传
查看>>
ASCII 码表对照
查看>>