LeetCode - Nth Highest Salary
题目大概意思是要求找出第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的更多相关文章
- [LeetCode] Nth Highest Salary 第N高薪水
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- LeetCode——Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- LeetCode 177. Nth Highest Salary
https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highe ...
- 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. +----+ ...
- find the Nth highest salary(寻找第N高薪水)
Suppose that you are given the following simple database table called Employee that has 2 columns na ...
- [SQL]LeetCode177. 第N高的薪水 | Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- 【SQL】177. Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- [LeetCode]-DataBase-Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- [LeetCode] Department Highest Salary 系里最高薪水
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
随机推荐
- Bit operator: Left shift and Right shift (Signed or unsigned? )
No matter left shift or right shift, the result's sign should always be the same as its left operand ...
- ansible unarchive模块
unarchive模块:http://docs.ansible.com/ansible/unarchive_module.html 功能:解压缩,这个模块有两种用法: 1.将ansible主机上的压缩 ...
- 7 款基于 JavaScript/AJAX 的文件上传插件
本文整理了7款基于JavaScript和AJAX的文件上传插件,这些插件基本上都能实现以下功能: 多文件上传 拖拽操作 实时上传进度 自定义上传限制 希望能为你的开发工作带来帮助. 1. jQuer ...
- WCF(二)
摘自:http://www.cnblogs.com/yank/p/3666271.html WCF入门教程(二)从零做起-创建WCF服务 通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK ...
- 同一页面中引入多个JS库产生的冲突解决方案(转)
发生JS库冲突的主要原因:与jQuery库一样,许多JS库都使用‘$’符号作为其代号.因此在一个页面中引入多个JS库,并且使用‘$’作为代号时,程序不能识别其代表哪个库(这个是我自己的解释,但更深的原 ...
- PhoneGap开发不可或缺的五件装备
PhoneGap是一种介于WebApp和NativeApp之间的解决方案,它为每种移动客户端提供一个Native的壳,这种壳里边包着一个Web应 用.借助于壳,Web应用可以被安装,可以被发布到各大市 ...
- js unicode处理
//岗位详细界面 var str="1.\u000D\u21B52.\u000D\u21B53"; var pad = function() { var tbl = []; ret ...
- 【Java面试题】18 java中数组有没有length()方法?string没有lenght()方法?下面这条语句一共创建了多少个对象:String s="a"+"b"+"c"+"d";
数组没有length()这个方法,有length的属性.String有有length()这个方法. int a[]; a.length;//返回a的长度 String s; s.length();// ...
- 算法--将Excel列索引转换成默认标识
使用POI导入Excel时,有时对模板进行验证,假如第1行第1列错误,此时的rowIndex=columnIndex=0,与平时看到的Excel行列标记相比不太直观,因此通过相应的算法将其转换成人们熟 ...
- c++ 类型定义
1. typedef map<int, CString> UDT_MAP_INT_CSTRING; UDT_MAP_INT_CSTRING enumMap;