题目大概意思是要求找出第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. init进程接管孤儿进程的验证

      #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include<stdlib ...

  2. protobuf--数据序列化及反序列化

    ProtoBuf是一种灵活高效的独立于语言平台的结构化数据表示方法,可用于表示通信协议和数据存储等各方面,与XML相比,ProtoBuF更小更快更简单.你可以用定义自己ProtoBuf的数据结构,用P ...

  3. oops_根据epc定位linux_kernel_panic位置

    韩大卫@吉林师范大学 2014.12.10 转载请表明出处 ***************************************************** 关于内核报错 “Unable t ...

  4. 电快速脉冲群EFT(概念)

    电快速瞬变脉冲群 简称EFT(Electrical Fast Transient)是指脉冲群有特定的持续时间(规定为15mS),特定的脉冲周期(300mS)的脉冲, 脉冲群中的单个脉冲有特定的重复周期 ...

  5. 使用C#创建windows 服务

    创建项目选择Windows Service 创建好项目之后,在生成的Service1.cs的设计页面右键选择Add Installer,会生成一个ProjectInstaller.cs.这个文件中有两 ...

  6. java多线程有几种实现方法?线程之间如何同步

    java中多线程的实现方法有两种:1.直接继承thread类:2.实现runnable接口: 同步的实现方法有五种:1.同步方法:2.同步代码块:3.使用特殊域变量(volatile)实现线程同步:4 ...

  7. PHP变量解析顺序variables_order

    转载自:http://blog.csdn.net/knight0450/article/details/4291556 故事从一个有点诡异的BUG开始,后台一个使用频率不是很高的广告提交功能有时候会莫 ...

  8. PHP并发IO编程之路

    并发IO问题一直是服务器端编程中的技术难题,从最早的同步阻塞直接Fork进程,到Worker进程池/线程池,到现在的异步IO.协程.PHP程序员因为有强大的LAMP框架,对这类底层方面的知识知之甚少, ...

  9. sql server merge 的用法

    CREATE TABLE tTable ( id INT , f1 VARCHAR(10) , f2 VARCHAR(10) , f3 VARCHAR(10) ) GO INSERT INTO tTa ...

  10. Batch Normalization原理及其TensorFlow实现——为了减少深度神经网络中的internal covariate shift,论文中提出了Batch Normalization算法,首先是对”每一层“的输入做一个Batch Normalization 变换

    批标准化(Bactch Normalization,BN)是为了克服神经网络加深导致难以训练而诞生的,随着神经网络深度加深,训练起来就会越来越困难,收敛速度回很慢,常常会导致梯度弥散问题(Vanish ...