[LeetCode] 176. Second Highest Salary_Easy tag: SQL
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 query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+
思路为先把最大的选出来, 然后把不等于之前的最大的, 最大的salary选出来即可.
SELECT max(Salary) as SecondHighestSalary FROM Employee WHERE Salary NOT IN (SELECT max(Salary) FROM Employee)
[LeetCode] 176. Second Highest Salary_Easy tag: SQL的更多相关文章
- 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 ...
- [LeetCode] 627. Swap Salary_Easy tag: SQL
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m v ...
- Leetcode 176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- [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 ...
- [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 ...
- [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 ...
- LeetCode 176. Second Highest Salary (第二高的薪水)
题目标签: 题目给了我们一个工资表,让我们返回第二高的工资. 利用Max,把第一高的工资找到,然后利用 NOT IN,去找到第二高的工资. Java Solution: Runtime: 153ms ...
- [LeetCode] 584. Find Customer Referee_Easy tag: SQL
Given a table customer holding customers information and the referee. +------+------+-----------+ | ...
- [LeetCode] 603. Consecutive Available Seats_Easy tag: SQL
Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you ...
随机推荐
- Django配合MySQL学习Django模型外键的建立和使用
Django 模型建立外键 在模型中建立外键是很简单的,基本操作如下 class Table(models.Model) column_name = models.ForeignKey(other-T ...
- 23种设计模式之中介者模式(Mediator)
中介者模式是一种对象的行为型模式,通过一个中介对象来封装一系列的对象交互.中介者使得各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互.中介者对象的存在保证了对象结构上的稳 ...
- DXP 内电层分割
多层电路板中间层设置与内电层如何分割 多层电路板与一般的电路板不同之处在于,多层电路板除了顶层和底层之外,还有若干中间层,这些中间层可以是信号层(mid layer),也可以是内部电源/接地层(int ...
- 【Android】Android import和export使用说明 及 export报错:jarlist.cache: Resource is out of sync with the file syst解决
在Android开发export项目时发现有时会报错,内容如下: Problems were encountered during export: Error exporting PalmIdent ...
- Making Promises With
转:Making Promises With http://www.htmlgoodies.com/beyond/javascript/making-promises-with-jquery-defe ...
- zTree实现节点修改的实时刷新
一.应用场景 在实际应用中会遇到动态操作树各节点的需求,在增加树节点后如何实时动态刷新树就十分有必要了. 二.项目实践 比如要在test1234节点下新建子节点,首先要选中test1234节点,添 ...
- Oracle安装部署之dbca静默建库和删除库
dbca查看帮助: [oracle@wen ~]$ dbca -help 1).运行静默建库语句 [oracle@wen ~]$ dbca -silent -cloneTemplate -gdbNam ...
- SS iproute2,nslookup,dig
从某种意义上说,iproute工具集几乎可以替代掉net-tools工具集,具体的替代方案是这样的:用途 net-tool(被淘汰) iproute2地址和链路配置 ifconfig ip ...
- ElasticSearch报 EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@c0efba
ElasticSearch报以下错误的解决办法: "type": "es_rejected_execution_exception", "reason ...
- redis 数据迁移
最近有个项目因为要搬迁服务器的原因,去找了服务器公司的运维,需要收费,于是果断决定自己实现这个功能.现在百度上已经一大把redis数据库迁移的教程,大部分是利用主从复制或者利用redis的RDB备份之 ...