Redian新闻
>
share New Thinkpad 15% off code
avatar
share New Thinkpad 15% off code# PDA - 掌中宝
H*7
1
我的答案一直得到wrong answer
SELECT Salary FROM Employee ORDER BY Salary DESC LIMIT N, 1
谁给指点一下!?谢谢
avatar
R*R
2
pring marks the arrival of the ThinkPad T460s, our latest evolution of the
best-selling ThinkPad in North America. This enterprise-ready Ultrabook
8482; is perfectly engineered for high productivity and low maintenance.
Save 15% with eCoupon code: SMBMARCHDEAL
can be used for Thinkpad T460S, New Thinkpad X1C Gen 4,
ThinkCentre M800z , and ThinkPad X260
Good luck !
avatar
a*a
3
select if(s=2147483648, null, s) from (
(select 2147483648 as s)
union all
(select distinct Salary as s from Employee)
) x
order by s Desc limit N, 1
这个可以过,但估计不是很好
avatar
b*1
4
在哪个网站可以用啊?在官网用不了啊。

【在 R***R 的大作中提到】
: pring marks the arrival of the ThinkPad T460s, our latest evolution of the
: best-selling ThinkPad in North America. This enterprise-ready Ultrabook
: 8482; is perfectly engineered for high productivity and low maintenance.
: Save 15% with eCoupon code: SMBMARCHDEAL
: can be used for Thinkpad T460S, New Thinkpad X1C Gen 4,
: ThinkCentre M800z , and ThinkPad X260
: Good luck !

avatar
z*u
5
Try this
SELECT DISTINCT(Emp1.Salary) FROM Employee Emp1 WHERE (N-1) = (SELECT COUNT(
DISTINCT(Emp2.Salary))
FROM Employee Emp2 WHERE Emp2.Salary > Emp1.Salary)
avatar
T*7
7
能简单解释一下么

COUNT(

【在 z*u 的大作中提到】
: Try this
: SELECT DISTINCT(Emp1.Salary) FROM Employee Emp1 WHERE (N-1) = (SELECT COUNT(
: DISTINCT(Emp2.Salary))
: FROM Employee Emp2 WHERE Emp2.Salary > Emp1.Salary)

avatar
s*y
8
这是mysql的解法吧
别的环境不管用的

【在 H******7 的大作中提到】
: 我的答案一直得到wrong answer
: SELECT Salary FROM Employee ORDER BY Salary DESC LIMIT N, 1
: 谁给指点一下!?谢谢

avatar
s*y
9
select name, salary from
(select name, salary, (rank ()over (order by salary desc)) as rank) tabel1
where table1.rank=n
avatar
z*u
10
The idea is just simple, in order to find the Nth highest salary , we just
find the salary that has exactly N - 1 salaries greater than itself.

【在 T******7 的大作中提到】
: 能简单解释一下么
:
: COUNT(

avatar
r*n
11
DECLARE M;
SET M=N-1;
SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT M, 1;
avatar
a*2
12
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
RETURN (
# Write your MySQL query statement below.
SELECT IF((SELECT COUNT(DISTINCT(Salary)) FROM Employee) < N, null,
orderedtable.Salary) AS 'NthHighestSalary'
FROM
(SELECT DISTINCT (Salary) AS Salary FROM Employee ORDER BY Salary
DESC LIMIT N) AS orderedtable
ORDER BY orderedtable.Salary ASC LIMIT 1
);
END
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。