Top-n query: Query to find the nth highest salary and the
associated employees from employees table
select a.last_name,a.salary
from employees a
where n = (select count(distinct(b.salary))
from employees b
where a.salary <= b.salary)
nth least query: Query to find the nth least or say 2nd least salary and
the associated employees from employees table
select a.last_name,a.salary
from employees a
where n = (select count(distinct(b.salary))
from employees b
where a.salary >= b.salary)
Thursday, January 18, 2007
Subscribe to:
Post Comments (Atom)






No comments:
Post a Comment