MongoDB: How to find nth highest salary from collection
问题 I need to find the nth highest salary in a mongodb from Employees collection. also would be really helpful if someone could gimme an idea of applying joins in mongodb. 回答1: This should work db.Employees.find({}).sort({"Emp salary":-1}).limit(1) //for first highest salary db.Employees.find({}).sort({"Emp salary":-1}).skip(1).limit(1) // for second highest salary Similarly you can do db.Employees.find({}).sort({"Emp salary":-1}).skip(nthVarible - 1).limit(1) . 回答2: Try this out: db.salary.find(