[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 ...
随机推荐
- TCP端口号范围及分类
https://blog.csdn.net/my_heart_/article/details/52601924 端口号的范围是从1-65535 端口的概念: 在网络技术中,端口(Port)大致有两 ...
- springboot---->集成mybatis开发(二)
这里面我们介绍一下springboot集成mybatis完成一对多数据和一对一数据的功能.任何一个人离开你 都并非突然做的决定 人心是慢慢变冷 树叶是渐渐变黄 故事是缓缓写到结局 而爱是因为失望太多 ...
- 为Docker容器中运行的gitlab添加ssh的一些问题记录
最近做的一个东西,是将gitlab10.x的汉化版本,从源码编译(在源码中自己定制一些东西),然后制作成Docker镜像,作为Docker容器来运行 在启用容器中的gitlab的ssh的时候,遇到了一 ...
- wget 无法建立ssl连接 [ERROR: certificate common name ?..ssl.fastly.net?.doesn?. match requested host name ?.ache.ruby-lang.org?. To connect to cache.ruby-lang.org insecurely, use ?.-no-check-certificate?]
通过wget下载文件,报错 [root@Redmine-186 opt]# wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.g ...
- Redmine插件的安装与卸载,知识库插件安装。
本文介绍linux版本的Redmine插件安装,通常Redmine安装在Linux系统,/var/www/redmine/路径. 安装: 复制插件到 2.X版本 #{RAILS_ROOT}/plugi ...
- html css的内联样式 内部样式表 外部样式表的优先级
http://www.w3school.com.cn/html/html_css.asp 这三种样式是有优先级的,记住他们的优先级:内联式 > 嵌入式 > 外部式,但是嵌入式>外部式 ...
- python3查询数据库并生成excel报表
#!/usr/bin/env python3 #encoding=UTF- import os import time import xlwt hostIp = 'xxx.xxx.xxx.xx' us ...
- 小程序中navigator和wx.navigateTo,wx.redirectTo,wx.reLaunch,wx.switchTab,wx.navigateBack的用法
如果用一句话来表明navigator和API中wx.系列的跳转有什么区别,那就是navigator是在wxml中用标签添加open-type属性来达到和wx.系列一样的效果. navigator的属性 ...
- ubuntu下绝对路径和相对路径的问题
绝对路径与相对路径 除了需要特别注意的FHS目录配置外,在文件名部分我们也要特别注意.因为根据档名写法的不同,也可将所谓的路径(path)定义为绝对路径(absolute)与相对路径(relativ ...
- HDU 3507 - Print Article - [斜率DP]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3507 Zero has an old printer that doesn't work well s ...