Ask Your Question
3

What is the process to obtain the 5th, 6th, and 7th highest salaries using Oracle SQL?

asked 2023-02-28 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-02-19 01:00:00 +0000

bukephalos gravatar image

To obtain the 5th, 6th, and 7th highest salaries using Oracle SQL, you can use the following SQL statement:

SELECT salary FROM (SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rank FROM employees) WHERE rank IN (5, 6, 7);

This SQL statement first selects the salary and its rank using the DENSE_RANK() function, which assigns the same rank to identical salary values and results in no gaps in ranking sequence. It then filters out the records with rank 5, 6, and 7 using the WHERE clause. Finally, it returns the salaries of the selected records.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-28 11:00:00 +0000

Seen: 8 times

Last updated: Feb 19 '22