且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从表中找出第n高的工资

更新时间:2023-12-01 09:34:58

你可以使用这样的东西..这是我测试过的然后粘贴在这里

you can use something like this.. this is what i have tested and then pasted here

SELECT *
FROM   tblname
WHERE  salary = (SELECT *
                 FROM   (SELECT *
                         FROM   (SELECT *
                                 FROM   (SELECT DISTINCT( salary )
                                         FROM   tblname
                                         ORDER  BY salary DESC) A
                                 WHERE  rownum <= nth) B
                         ORDER  BY salary ASC) C
                 WHERE  rownum <= 1) 

代替 'tblname' 给出你的表名,然后在 nth 给出你想要的第 n 高薪

in place of 'tblname' give your table name and then in place nth give your desired nth highest salary that you want

您可以在屏幕截图中看到它正在工作.

you can see in the screen shot that it is working.