some one help me to find out nth highest salary from the salary table in MYSQL
The NTH_VALUE() function explicitly shows you the value of the third-highest salary by department. The ROW_NUMBER() , RANK() , and DENSE_RANK() functions rank the salaries within each department. Then, you can simply find the salary value associated with rank number 3.
Step 2: Find the nth highest salary We will use the min function and the limit keyword. The nth highest salary is the minimum salary among the top n rows of A . The min function returns the minimum value for a column in a table. The limit function returns the first n rows.
Try this, n would be the nth item you would want to return
SELECT DISTINCT(Salary) FROM table ORDER BY Salary DESC LIMIT n,1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With