zoukankan      html  css  js  c++  java
  • #Leetcode# 183. Customers Who Never Order

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

    Suppose that a website contains two tables, the Customers table and the Orderstable. 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       |
    +-----------+

    代码:

    # Write your MySQL query statement below
    SELECT Name AS Customers FROM Customers WHERE Customers.Id NOT IN
    (SELECT Orders.CustomerId FROM Orders)
    

      

  • 相关阅读:
    问题6-10
    7.19 1
    经济学人常见词汇清单
    英语广播原声听力100篇MP3及听力原文
    6.30.2018
    6.26
    6.26
    6.26
    6.25
    6.25
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/10848755.html
Copyright © 2011-2022 走看看