题目大概意思是要求找出第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. pthread_once函数的简单示例

    /*一次性初始化 int pthread_once(pthread_once_t *once_control, void (*init_routine) (void)) 本函数使用初值为PTHREAD ...

  2. Android—— TextView文字链接4中方法

    转自:http://ghostfromheaven.iteye.com/blog/752181 Android 的实现TextView中文字链接的方式有很多种. 总结起来大概有4种: 1.当文字中出现 ...

  3. linux下获取服务器硬件信息的脚本

    这是个简单的脚本,便于查询服务器的硬件信息: #!/bin/bash # # Description: # Used to get the hardware config information. # ...

  4. jQuery客户端分页

    01 <script src="/js/jquery-1.4.1.js" type="text/javascript"></script> ...

  5. VC dimension(Vapnik-Chervonenkis dimension)

    二维平面的线性分类器的VC维讨论:http://www.tuicool.com/articles/JjaMfe VC维介绍:http://blog.csdn.net/lucylove3943/arti ...

  6. Spring bean的初始化及销毁

    Spring bean的几个属性:scope.init-method.destroy-method.depends-on等. Scope 在Spring容器中是指其创建的Bean对象相对于其他Bean ...

  7. 如果不得已需要全局变量,则使全局变量加前缀 g_(表示 global)

    如果不得已需要全局变量,则使全局变量加前缀 g_(表示 global). 例如: int g_howManyPeople; // 全局变量 int g_howMuchMoney; // 全局变量 #i ...

  8. C/C++,从未过时的编程语言之父

    C/C++,持续火爆的编程语言之父 --訪传智播客C/C++学院院长传智·萧峰 编程语言作为实现互联网+基础必备工具,构建着互联网行业美轮美奂的大时代.作为编程语言之父--C语言,更是如鱼得水,在甘愿 ...

  9. C#接口之IEnumerable,IEnumerator

    IEnumerable 截图来源于https://msdn.microsoft.com/zh-cn/library/system.collections.ienumerable.getenumerat ...

  10. App 应用通过网页打开 App Store

    NSURL *url = nil; if ([[[UIDevice currentDevice] systemVersion] intValue] >= 7.0) { //iOS7 使用旧的网址 ...