1. 程式人生 > >leetcode 177. Nth Highest Salary

leetcode 177. 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 highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null

.

Subscribe to see which companies asked this question

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
    set N=N-1;
  RETURN (
      # Write your MySQL query statement below.
      select distinct e.Salary from Employee e order by Salary Desc limit N,1
  );
END


相關推薦

leetcode 177. Nth Highest Salary

Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 |

LeetCode-Algorithms #003 Longest Substring Without Repeating Characters, Database #177 Nth Highest Salary

LeetCode-Algorithms #003 Longest Substring Without Repeating Characters  對於給定的字串, 找出其每個字元都不重複的子串中最長的那個, 並返回該子串的長度: 想法還是遍歷: 1 class Solution { 2 pu

177. Nth Highest Salary (Medium)

desc nth logs esc employee example leetcode turn begin Source: https://leetcode.com/problems/nth-highest-salary/#/descriptionDescription:

LeetCode Nth Highest Salary

Problem Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--

LeetCode】Second Highest Salary && Nth Highest Salary

Total Accepted: 1030 Total Submissions: 4309 My Submissions Question Solution Write a SQL query to get the second highest salary from th

177. 第N高的薪水(Nth Highest Salary

題目: 編寫一個 SQL 查詢,獲取 Employee 表中第 n 高的薪水(Salary)。 +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | |

sql leetcode 176. Second Highest Salary

Write a SQL query to get the second highest salary from the Employeetable. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2

leetcode 2--Second Highest Salary

https://leetcode.com/problems/second-highest-salary/description/ Write a SQL query to get the second highest salary from the Employee table. +—

Nth Highest Salary 解法討論(Mysql)

最近在做資料庫的練習,一道LeetCode 上的題目花了我一個小時分析不同解法,在此記錄一下。 題目描述 Write a SQL query to get the nth highest salary from the Employee table

leetcode 176. Second Highest Salary

Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200

Nth Highest Salary

Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 |

leetcode.184. Department Highest Salary

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+---

Leetcode】 Second Highest Salary

題目: Write a SQL query to get the second highest salary from the Employee table. +—-+——–+ | Id |

LeetCode-第二高的薪水(second-highest-salary)

第二高的薪水 難度 簡單 更多LeetCode答案歡迎大家關注Github: https://github.com/lxyer/LeetCodeAnswer 編寫一個 SQL 查詢,獲取 Employee 表中第二高的薪水(Salary) 。 +----+---

LeetCode Second Highest Salary

Problem Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----

[LeetCode] Department Highest Salary 系裡最高薪水

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+---

[LeetCode] Second Highest Salary 第二高薪水

Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 2

LeetCode】184. Department Highest Salary

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+----

Leetcode: Department Highest Salary

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +—-+

176. Second Highest SalaryLeetcode)

文章出處:http://www.cnblogs.com/grandyang/p/5348961.html Write a SQL query to get the second highest salary from the Employee table. +----+