gpt4 book ai didi

mysql - 如何在不使用限制的情况下在MySql中找到前5名薪水

转载 作者:行者123 更新时间:2023-11-29 04:18:28 26 4
gpt4 key购买 nike

以下查询在 MySql 中不起作用。

SELECT * /*This is the outer query part */
FROM Employee Emp1
WHERE (N-1) = ( /* Subquery starts here */
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)

帮帮我。

最佳答案

试试这个:

SET @n := 0;
SELECT * FROM
(SELECT salary, @n := @n + 1 AS t1 FROM Employee ORDER BY salary DESC)
AS t
WHERE t1 <= 5

Working DEMO

关于mysql - 如何在不使用限制的情况下在MySql中找到前5名薪水,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33252604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com