BOX8 | Ranking in SQL

Question

Assume table and columns
Get me the name of the lowest salary from each department

in progress 0
TheDataMonk 55 years 4 Answers 1226 views Grand Master 0

Answers ( 4 )

  1. with cte as (
    Select department, salary, , rank () over (partition by department order by salary asc ) as Min_Sal
    from Table
    )
    Select * from cte
    where min_sal=1

  2. select empname from employeeswhere empname = (select empname,
    min(sal) from employees
    group by department)

  3. select name, department, rank() over(partition by department order by salary asc) as sal_rank
    from table
    where sal_rank =1;

  4. SELECT Name FROM
    (SELECT Name , MIN(Salary) from table GROUP BY Department)

Leave an answer

Browse
Browse