Given a table customer holding customers information and the referee.

+------+------+-----------+
| id | name | referee_id|
+------+------+-----------+
| 1 | Will | NULL |
| 2 | Jane | NULL |
| 3 | Alex | 2 |
| 4 | Bill | NULL |
| 5 | Zack | 1 |
| 6 | Mark | 2 |
+------+------+-----------+

Write a query to return the list of customers NOT referred by the person with id '2'.

For the sample data above, the result is:

+------+
| name |
+------+
| Will |
| Jane |
| Bill |
| Zack |
+------+

note: 要用 is Null 和 != .

Code

SELECT name FROM customer WHERE referee_id != 2 OR referee_id IS NULL

[LeetCode] 584. Find Customer Referee_Easy tag: SQL的更多相关文章

  1. [LeetCode] 619. Biggest Single Number_Easy tag: SQL

    Table number contains many numbers in column num including duplicated ones.Can you write a SQL query ...

  2. [LeetCode] 620. Not Boring Movies_Easy tag: SQL

    X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...

  3. [LeetCode] 176. Second Highest Salary_Easy tag: SQL

    Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...

  4. [LeetCode] 196. Delete Duplicate Emails_Easy tag: SQL

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  5. [LeetCode] 603. Consecutive Available Seats_Easy tag: SQL

    Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you ...

  6. [LeetCode] 64. Minimum Path Sum_Medium tag: Dynamic Programming

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  7. [LeetCode] 586. Customer Placing the Largest Number of Orders_Easy tag;SQL

    Query the customer_number from the orders table for the customer who has placed the largest number o ...

  8. [LeetCode] 607. Sales Person_Easy tag: SQL

    Description Given three tables: salesperson, company, orders.Output all the names in the table sales ...

  9. [LeetCode] 181. Employees Earning More Than Their Managers_Easy tag: SQL

    The Employee table holds all employees including their managers. Every employee has an Id, and there ...

随机推荐

  1. 学习vue 2.x源码笔记

    1.响应式原理: 核心:Object.defineProperty,用法如下: var obj1 = {}; var initValue = 'hello'; Object.definePropert ...

  2. js函数 test.caller 谁在调用test函数

    返回调用指定函数的函数. function test() { if (test.caller === null) console.log('test 函数在全局调用'); // 获取调用 test函数 ...

  3. 洛谷P1216 数字三角形【dp】

    题目:https://www.luogu.org/problemnew/show/P1216 题意: 给定一个三角形.从顶走到底,问路径上的数字之和最大是多少. 走的时候可以往左下(实际上纵坐标不变) ...

  4. TOP100summit2017:网易云通信与视频CTO赵加雨:外力推动下系统架构的4个变化趋势

      壹佰案例:很荣幸邀请到您成为第六届壹佰案例峰会架构专场的联席主席,您曾深度参与Cisco Jabber,Webex Meeting, Cisco Spark等多项分布式实时通信类产品的架构与研发, ...

  5. 23. 合并K个排序链表

    一种方法是分治  类似快排的例子. 第二种使用堆,比较好理解.  堆中保存一个元素是一个链表的头部. /** * Definition for singly-linked list. * public ...

  6. jdbc-------JDBCUtil类 工具类

    jdbcutil 主要处理的是 连接数据库, 和关闭各个流 1, 数据库连接的配置信息: mysql.properties (在工程的目录下)个人配置 url=jdbc:mysql://localho ...

  7. day3_字典

    一.说明 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典包括在花括号({})中 ,格式如下所示: dict = {key1:value1,key2 ...

  8. Kubernetes应用管理

    除了容器资源管理和调度,Kubernetes另外一个核心价值是提供了针对不同类型应用管理的API接口集合,这些API集合把针对不同类型应用的管理能力分别到Kubernetes平台中.以Web业务(Lo ...

  9. 使用Git,如何忽略不需要上传的文件(配置文件)

    步骤1:在目录下,选择GIt Bash Here 2.输入命令 : git update-index --assume-unchanged 文件名 3.再输入指令 git  status 查看修改文件 ...

  10. 重读《深入理解Java虚拟机》一、Java虚拟机内存区域的划分

    一.Java虚拟机内存区域如何划分 1.Java虚拟机内存区域的划分 区域名称 作用(用途) 类型 特点 虚拟机规定异常情况 内存分配与回收 其他说明 1 程序计数器 指示当前正在执行的字节码指令地址 ...