select if(count(salary) = 0, NULL, salary) as `salary` from (
select salary from Employee group by salary order by salary desc limit 1,1) tmp

Write a SQL query to get the second highest salary from the Employee table.

+----+--------+
| Id | Salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+

For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null.

对于null的处理稍烦

LeetCode SQL: Second Highest Salary的更多相关文章

  1. LeetCode 176 Second Highest Salary mysql,select 嵌套 难度:1

    https://leetcode.com/problems/second-highest-salary/ Write a SQL query to get the second highest sal ...

  2. LeetCode 177. Nth Highest Salary

    https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highe ...

  3. Leetcode 176. Second Highest Salary

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

  4. LeetCode DB: Department Highest Salary

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...

  5. [LeetCode#184]Department Highest Salary

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...

  6. LeetCode 176. Second Highest Salary (第二高的薪水)

    题目标签: 题目给了我们一个工资表,让我们返回第二高的工资. 利用Max,把第一高的工资找到,然后利用 NOT IN,去找到第二高的工资. Java Solution: Runtime:  153ms ...

  7. [LeetCode] Department Highest Salary 系里最高薪水

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...

  8. [LeetCode] Nth Highest Salary 第N高薪水

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

  9. [LeetCode] Second Highest Salary 第二高薪水

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

随机推荐

  1. 我编写 33 个 VSCode 扩展的原因以及管理扩展的经验

    简评:使用工具的同时自己创造一些工具或扩展,是一件很棒的事情. 以下"我"指原作者 Fabio 大家好,我叫 Fabio,是一位自学成才的开发人员,热衷于开源和授权.我也喜欢自己制 ...

  2. 各大浏览器相继发布声明将停止支持 TLS 1.0 和 TLS 1.1 !

    简评:TLS 1.0 发布至今已将近 20 周年即将寿终正寝,期间为我们保障了千亿次甚至万亿次的数据请求安全. TLS 工作组几个月前发布声明文件弃用 TLS 1.0 和 TLS 1.1. 昨天,包括 ...

  3. Java性能优化技巧及实战

    关于Java代码的性能优化,是每个javaer都渴望掌握的本领,进而晋升为大牛的必经之路,但是对java的调优需要了解整个java的运行机制及底层调用细节,需要多看多读多写多试,并非一朝一夕之功.本文 ...

  4. table组件选中数据回显

    table组件多选状态下,把已选择的数据回显,需要在多选列上加上一个属性 :reserve-selection="true" 实例如下: <el-table :data=&q ...

  5. 题解 p2420 让我们异或吧

    传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; ;in ...

  6. CF1139D Steps to One 题解【莫比乌斯反演】【枚举】【DP】

    反演套 DP 的好题(不用反演貌似也能做 Description Vivek initially has an empty array \(a\) and some integer constant ...

  7. 求幂大法,矩阵快速幂,快速幂模板题--hdu4549

    hdu-4549 求幂大法.矩阵快速幂.快速幂 题目 M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 ...

  8. Logback 学习笔记

    来源:http://webinglin.github.io/2015/06/04/Logback-%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/ Logback背景 Log ...

  9. *2_3_5_加入reference model

    摘自:http://book.2cto.com/201408/46009.html 在2.1节中讲述验证平台的框图时曾经说过,reference model用于完成和DUT相同的功能. referen ...

  10. Spring多线程编程

    在Spring框架下如何保证线程安全,如何很happy顺畅地并发编程. 常见的如下面的这坨代码,在Spring中,默认是单例的,也就是说,在同一时刻只有一个SpringOrdinaryClass的单实 ...