From 6dc33e0f75035ee46aa47e4413c9a0bd211f7bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=E1=BB=93=20V=C4=83n=20H=C3=B2a?= <56647826+hovanhoa@users.noreply.github.com> Date: Mon, 23 Oct 2023 23:30:21 +0700 Subject: [PATCH] Time: 1064 ms (14.5%), Space: 0B (100%) - LeetHub --- 0177-nth-highest-salary/0177-nth-highest-salary.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 0177-nth-highest-salary/0177-nth-highest-salary.sql diff --git a/0177-nth-highest-salary/0177-nth-highest-salary.sql b/0177-nth-highest-salary/0177-nth-highest-salary.sql new file mode 100644 index 0000000..fa8e0ae --- /dev/null +++ b/0177-nth-highest-salary/0177-nth-highest-salary.sql @@ -0,0 +1,9 @@ +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT +BEGIN +SET N = N-1; + RETURN ( + # Write your MySQL query statement below. + SELECT DISTINCT(salary) from Employee order by salary DESC + LIMIT N,1 + ); +END \ No newline at end of file