sql - Is this method correct to find second or third or fourth highest value in a column in mysql -
sql - Is this method correct to find second or third or fourth highest value in a column in mysql -
i have table (name "friend") in mysql , want select 2nd or 3rd or 4th highest amount (i.e salary) table.
i using method:
`select * friends order salary desc limit 1; -- highest salary.`
and
`select * friends order salary desc limit 1 offset 1; -- sec highest salary.`
and
`select * friends order salary desc limit 1 offset 2; -- 3rd highest salary.`
is method right or have utilize logical method like.
`select * friends salary = (select max(salary) friends salary < (select max(salary) friends)); -- sec highest salary`.
please tell me professional method.
the limit offset preferred , more legibale;
select * friends order salary desc limit 3,1;
mysql sql
Comments
Post a Comment