To find the nth highest salary or highest score in a table, below is the query to find out.
SELECT * FROM employee a WHERE n = (SELECT COUNT(*) FROM employee b WHERE a.salary <= b.salary) ;
'n' --> By replacing n with the required value we can get the second, third, fourth highest and so on..
SELECT * FROM employee a WHERE n = (SELECT COUNT(*) FROM employee b WHERE a.salary <= b.salary) ;
'n' --> By replacing n with the required value we can get the second, third, fourth highest and so on..
1 comment:
thanks for your post
Post a Comment