176. Second Highest Salary


1. 问题描写叙述:

写一个sql语句从 Employee 表里获取第二高位的工资。

2. 解决思路:

这道题非常easy,就当热身了。首先用max找到最高工资。

然后去找小于最高工资里的最高工资就是第二高的工资。

3. sql语句:

select Max(Salary)
from Employee
where Salary < (select Max(Salary) from Employee)

4. 执行时间:


希望多多交流指正!

LeetCode_Mysql_Second Highest Salary的更多相关文章

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

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

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

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

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

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

  4. 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 ...

  5. leetcode Database3(Nth Highest Salary<—>Consecutive Numbers<—>Department Highest Salary)

    一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+ ...

  6. TSQL Beginners Challenge 1 - Find the second highest salary for each department

    很久以前准备写的系列文章,后来因为懒一直耽搁着,今天突然决定继续下去,于是有了这篇文章,很基础,但很常用.题目描述依然拷贝.简单来说就是找出个个部门薪水排名第二的人,排名相同的要一起列出来. Intr ...

  7. Leetcode 176. Second Highest Salary

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

  8. find the Nth highest salary(寻找第N高薪水)

    Suppose that you are given the following simple database table called Employee that has 2 columns na ...

  9. [SQL]LeetCode176. 第二高的薪水 | Second Highest Salary

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

随机推荐

  1. AttributeError: 'dict' object has no attribute 'encode'

    首先这是一个很简单的 运行时错误: 错误分析: AttributeError:属性错误,造成这种错误的原因可能有: 你尝试访问一个不存在的属性或方法.检查一下拼写!你可以使用内建函数 dir 来列出存 ...

  2. PyQt5实现第一个桌面应用程序

    import sysfrom PyQt5.QtWidgets import QApplication,QWidget,QDialogfrom PyQt5.QtCore import Qt if __n ...

  3. [BZOJ] 2431 逆序对数列

    Time Limit: 5 Sec Memory Limit: 128 MB Submit: 2611 Solved: 1526 [Submit][Status][Discuss] Descripti ...

  4. LINUX:Contos7.0 / 7.2 LAMP+R 下载安装Redis篇

    文章来源:http://www.cnblogs.com/hello-tl/p/7569108.html 更新时间:2017-09-21 16:09 简介 LAMP+R指Linux+Apache+Mys ...

  5. WSS、SSL 和 https 之间的关系

    SSL SSL(Secure Socket Layer,安全套接层) 简单来说是一种加密技术, 通过它, 我们可以在通信的双方上建立一个安全的通信链路, 因此数据交互的双方可以安全地通信, 而不需要担 ...

  6. idea+Maven+SSM框架增删改查

    完整项目结构 1.maven配置文件pom.xml <?xml version="1.0" encoding="UTF-8"?> <!-- L ...

  7. intellij idea 忽略文件不提交

    文件已经纳入版本管理 如果文件已经纳入版本了,应该采用此方法 此方法主要应对文件已经纳入版本管理,但不想再提交,比如,不小心提交的eclipse.intellij的文件,以后不想再提交了,这种就通过v ...

  8. [luoguP1494] 岳麓山上打水 && [luoguP2744] [USACO5.3]量取牛奶Milk Measuring

    传送门 传送门 dfs选取集合,dp背包判断 虽然我觉的会TLE.. 但是的确是AC了 #include <cstdio> #include <cstring> #includ ...

  9. Codeforces915F. Imbalance Value of a Tree

    n<=1e6的树问所有路径的极差之和. 被遗忘的套路...以后绝对不会再忘了QAQ 只要算最大值之和即可,最小值同理.数字从大到小排序(反正都是要排序的,如果从大到小不行等会反过来试试),然后逐 ...

  10. 通过setContentView设置activity的不同样式

    public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle saved ...