183. Customers Who Never Order

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

 

answer:SELECT Name as Customers  FROM Customers WHERE id not in (select CustomerId from Orders ) 

posted on 2016-07-14 20:59  Lorryrui  阅读(146)  评论(0编辑  收藏  举报