Thứ Năm, 26 tháng 8, 2010

How to find third highest salary from a database table by sql or mysql

By this query you can find all possible(nth) highest salary starting from 2nd to nth.Just palace your find number salary in the place of `n` and you can get result. Here I have wrote the `n`th highest salary.




Select salary

from `tablename`

order by `columnname` desc

limit n-1,1;




Write 2 instead of n-1 to find the 3rd highest salary.Write 1 instead of n-1 to find the 2nd Highest salary.

Không có nhận xét nào:

Đăng nhận xét