https://leetcode.com/problems/nth-highest-salary/ ATTENTION:limit 子句只能接受int常量,不能接受运算式 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN SET N = N - 1; RETURN ( # Write your MySQL query statement below. select DISTINCT Salary from Employee…
https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, gi…
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highest salary where n =…
https://leetcode.com/problems/second-highest-salary/ Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given th…
题目链接:https://leetcode.com/problems/nth-highest-salary/description/ 题意:查询出表中工资第N高的值 思路: 1.先按照工资从高到低排序(注意去重) select distinct Salary from Employee order by Salary desc 2.使用rownum给查询出的数据标注行号 select rownum ro, s.Salary from (select distinct Salary from Em…
问题描述 解决方案 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN declare number int; set number=N-1; return (select distinct Salary from Employee order by Salary desc limit number,1); END…
转自http://www.cnblogs.com/study100/archive/2013/07/30/3224250.html 在mysql中是没有top关键字的,在mysql中可以用limit来完成功能. order by id desc limit 10 按照id的倒序排序 取出前10条order by id desc limit 0,10 按照id的倒序排序 取出前10条order by id limit 5,10 按照id的正序排序 从第5条开始取10条 sql语句: SELECT…
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highest salary where n =…
一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth hig…
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highest salary where n =…