1. 程式人生 > >Nth Highest Salary

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
DECLARE M INT;
SET M=N-1;
  RETURN (
      # Write your MySQL query statement below.
    SELECT DISTINCT Salary FROM Employee ORDER by Salary DESC LIMIT M,1  
  );
END

相關推薦

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 | +----+--

Nth Highest Salary 解法討論(Mysql)

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

【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

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

Nth Highest Salary

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

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 |

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

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

176. Second Highest Salary(Easy)

tco targe query rip con -s second count rom Source of the question Write a SQL query to get the second highest salary from the Employee t

184. Department Highest Salary (medium)

https pro table select company leet have fin ems Source: https://leetcode.com/problems/department-highest-salary/#/descriptionDescription

176. Second Highest Salary

max color class statement select mysql ble clas cond Write a SQL query to get the second highest salary from the Employee table. +----+-

找第二大的數SQL-Second Highest Salary

des rom tin .com begin get pre sql 最大 1: 找小於最大的最大的 select max(Salary) from Employee where Salary<(select MAX(Salary) from Employe

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-第二高的薪水(second-highest-salary)

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

176. Second Highest Salary SQL查詢語句中的 limit offset

題目: 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 the ab

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. +—

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. +----+---

176.Second Highest Salary

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

LeetCode Second Highest Salary

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

[SQL]LeetCode184. 部門工資最高的員工 | 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. +----+-------+----