Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
select sal from (
select sal, dense_rank() over(order by sal desc) rnk from emp)
where rnk<5
SELECT EMPNO,ENAME.SAL
FROM
(
SELECT EMPNO,ENAME,SAL,ROW_NUMBER()OVER(PARTITION BY DEPTNO ORDER BY SAL) AS RNK FROM EMP
)A
WHERE A.RNK<=5
Select * From (SELECT A.*,
(SELECT COUNT(DISTINCT(B.salary))
FROM Employee B
WHERE B.salary >= A.salary and A.departmentID=B.departmentID) as Rank FROM Employee A) Emp
Where Emp.Rank <=5
select * from (select * from employees order by salary desc) where rownum<= 5 ORDER BY salary;
SELECT TOP 5 b.DepartName,a.Salary FROM Employee a
JOIN
Department b ON a.DepartId=b.DepartId
group by b.DepartName ORDER BY a.Salary DESC
SELECT DISTINCT DEPARTMENT_ID, salary,row_number() OVER (PARTITION BY DEPARTMENT_ID ORDER BY salary DESC) row_no FROM hr.employees
;with temp as
(
select dept, salary ,ROW_NUMBER() over (partition by dept order by salary desc) row_no from Employee
)
select dept,salary from temp where row_no <=5
SELECT DISTINCT department_no, salary FROM (SELECT department_no, salary, DENSE_RANK () OVER (PARTITION BY department_no ORDER BY salary DESC NULLS LAST) rn FROM employees) WHERE rn <=5 ORDER BY department_no, salary DESC;