Nth-maximum-salary.pdf

  • Uploaded by: Debasish Mohapatra
  • 0
  • 0
  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Nth-maximum-salary.pdf as PDF for free.

More details

  • Words: 133
  • Pages: 1
Select Nth maximum salary from a table Write a query to select Nth maximum salary from EMP table (or) Write a query to find 2nd, 3rd max salary from EMP table (or) Write a query to find 10 highest salary (Or) Write a query to find 4th highest salary (without analytical function) Answer:

We can achieve this by using the correlated sub query. In the below example we are getting the 5th highest salary without using the Analytical function. select * from emp emp1 where (5-1) = ( select count(distinct(emp2.sal)) from emp emp2 where emp2.sal > emp1.sal ) In the below example we are getting the 5th highest salary by using the Analytical function. select * from ( select e.*, DENSE_RANK() over (order by sal DESC) RN from emp e ) where RN=5

More Documents from "Debasish Mohapatra"

Untitled Presentation.pdf
December 2019 7
W1.docx
November 2019 13
W2.docx
November 2019 16