题目大概意思是要求找出第n高的Salary,直接写一个Function。作为一个SQL新手我学到了1.SQL中Function的写法和变量的定义,取值。2.limit查询分    页的方法。

在这个题目中limit n-1, 1是从n-1开始取出一条数据。这样说比较直观。

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
declare M int;
set M=N-1;
RETURN (
# Write your MySQL query statement below.
select distinct Salary from Employee order by Salary desc limit N-1, 1
);
END

LeetCode - Nth Highest Salary的更多相关文章

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

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

  2. LeetCode——Nth Highest Salary

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

  3. LeetCode 177. Nth Highest Salary

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

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

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

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

  6. [SQL]LeetCode177. 第N高的薪水 | Nth Highest Salary

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

  7. 【SQL】177. Nth Highest Salary

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

  8. [LeetCode]-DataBase-Nth Highest Salary

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

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

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

随机推荐

  1. netfiler/iptables

    一. 什么是netfilter netfilter is a set of hooks inside the Linux kernel that allows kernel modules to re ...

  2. redis的window客户端下载地址

    这里是window的版本,由微软维护的: https://github.com/MicrosoftArchive/redis/releases

  3. http抓包工具

    fiddler 可以用该工具抓包并修改对应的参数数据

  4. apt-get install 的替换命令及mysql安装问题的解决

    Some packages could not be installed. This may mean that you haverequested an impossible situation o ...

  5. 网络openvpn各种问题

    今天先配置在同一个vmc下的一个openvpn里的两个虚拟机,同一个网段 一开始出现了如下问题: eth0: ERROR while getting interface flags: No such ...

  6. Laravel 多where组合

    $model=DB::table("user"); foreach($request as $value){ if($value->name){ $model->whe ...

  7. 从 QA 到 EP

    两三年以前,和友人谈到 QA(软件质量保证) 这个行业,还有 QA 这个团队的未来,就有了一丝忧虑.而现在,终于有机会实践一下自己之前的想法,在这里分享给大家. 从我有限的从业经验到现在,经历了很多次 ...

  8. 上传图片(示列分析) $_FILES

    新建一个think_photo数据库,库里用sql CREATE TABLE IF NOT EXISTS `think_photo` ( `id` ) NOT NULL AUTO_INCREMENT, ...

  9. imx6 spi分析

    /************************************************************************** *本文主要跟踪imx6 spi设备和驱动的注册过 ...

  10. windows下安装TA-Lib库

    步骤一: https://sourceforge.net/projects/ta-lib/files/ta-lib/0.4.0/ta-lib-0.4.0-msvc.zip/download?use_m ...