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 ...
随机推荐
- SpringMVC 之类型转换Converter详解转载
SpringMVC之类型转换Converter详解 本文转载 http://www.tuicool.com/articles/uUjaum 1.1 目录 1.1 目录 1.2 ...
- win7配置ftp服务器
1.安装FTP,打开控制面板,找到程序和功能-->打开或者关闭windows功能,在列表中,展开internet信息服务,勾选FTP服务器,展开WEB管理工具,勾选IIS管理控制台,然后点击确定 ...
- Js加密与解密
<html><head><META HTTP-EQUIV="MSThemeCompatible" CONTENT="Yes"> ...
- 数学符号arg含义
argument of the maximum/minimum arg max f(x): 当f(x)取最大值时,x的取值 arg min f(x):当f(x)取最小值时,x的取值 表示使目标函数取最 ...
- 用javascript将数据导入Excel
网上收集的代码 <input type="button" name="out_excel" onclick="AutomateExcel();& ...
- CSRF简单介绍及利用方法
x00 简要介绍 CSRF(Cross-site request forgery)跨站请求伪造,由于目标站无token/referer限制,导致攻击者可以用户的身份完成操作达到各种目的.根据HTTP请 ...
- android LayoutInflater 笔记
LayoutInflater类用于查找布局文件并实例化.用于动态将布局加入界面中. 参考链接 http://blog.csdn.net/guolin_blog/article/details/1292 ...
- netsnmp编译动态库
.编译动态库 将写完的snmp代理程序编译生成动态库 gcc -c -fpic telnetConfig.c -o telnetConfig.o -I/usr/local/net-snmp/inclu ...
- 第二百八十二节,MySQL数据库-MySQL视图
MySQL数据库-MySQL视图 1.视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用. 2.也 ...
- Yii2框架加入API Modules
一.环境部署 1. read fucking Yii Documents. http://www.yiichina.com/doc/guide/2.0 2. 了解依赖注入模式 Java描写叙述: ht ...