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 employee with MAX salary department wise without using RANK or DENSE_RANK