Problem: How to find second highest salary from Employee table.
Concept: We need to find out the second highest salary from employee table. Below are showing two ways to achieve this.
Method 1: Using SUB Query
In this we have two query parent and child query. Using child query we are going to find maximum salary. In parent query we find the max salary which is less than the result of sub query.
Method 2: Using DENSE_RANK Function (Why we are not using RANK function here? Check this in difference between RANK and DENSE_RANK)
In this give rank to each row on the basis of salary. Once done filter the required rank from the main result set.
Your comments, queries and suggestions are welcomed.
Please login to post your valuable comments.
Get the latest vLemonn news first