簡體   English   中英

為什么查詢找到員工的第二高工資是不是在mysql 5.1中工作?

[英]why query to find the 2nd highest salary of the employee is not working in mysql 5.1?

我想找到第二高薪員工的薪水。

我的預期輸出是9000但它打印14000.我無法找到我的錯誤。 請幫助我

在此輸入圖像描述

在此輸入圖像描述

在此輸入圖像描述

試試這個查詢

select max(salary) from table_name
where salary< (select max(salary) from table_name)

小提琴

您也可以使用此查詢,

SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees)

只需使用子查詢從employees表中獲取最大薪水,並檢查相同,以獲得第二高。

Select * from table order by salary desc limit 2,1 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM