Tuesday, September 12, 2017

183. Customers Who Never Order

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

select C.Name as Customers
from Customers as C
where C.Id not in (select Orders.CustomerId from Orders);

select C.Name as Customers
from Customers as C
left join Orders on C.Id = Orders.CustomerId
where Orders.CustomerId is null

select C.Name as Customers
from Customers as C

where not exists (select CustomerId from Orders where C.Id = Orders.CustomerId);

No comments:

Post a Comment