mysql - I want to find the person with the 22nd highest salary -



mysql - I want to find the person with the 22nd highest salary -

i using mysql, have 50 records in employee table. want find person 22nd highest salary.

use limit, specifying both offset , row count.

to 22nd ranked person in order of highest salary, do:

select person employee order salary desc limit 21, 1

notice utilize of 21 here. because offset of initial row (1st highest salary) 0. hence 22nd highest salary offset of 21 (the 21st row in 0-based counting, or "skip 21 rows").

to person(s) 22nd highest salary, need 1 more level of indirection. try:

select person employee salary = ( select distinct salary employee order salary desc limit 21, 1 )

mysql

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -