[英]why query to find the 2nd highest salary of the employee is not working in mysql 5.1?
我想找到第二高薪員工的薪水。
我的預期輸出是9000但它打印14000.我無法找到我的錯誤。 請幫助我
您也可以使用此查詢,
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.