SQL Query to Find employee with MIN salary department wise

etldevloper
1 Min Read
Find employee with MIN salary department wise

SQL Query to Find employee with MIN salary department wise

SELECT * FROM(

       SELECT Employee_Id,

              First_Name,

              Department_Id,

              Salary,

              RANK() OVER(PARTITION BY Department_Id ORDER BY Salary) as SAL_RANK

       FROM EMPLOYEES

)

WHERE SAL_RANK =1;

If the question is to find the employee with 2nd max or min salary change the SAL_RANK accordingly in the query.

Also Read :

Find the difference between the salary of an employee and max salary of the employee in the department

Find employee with MAX salary department wise without using RANK or DENSE_RANK

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *