To solve Question 1 use the following query: select name,dept,salary from emp e where salary = (select max(salary) from emp where dept = e.dept ) order by dept
For duplicates, With CTE (Select *, row_number() over (partition by dept,name,salary order by salary) as rnk from emp) SELECT * from CTE where rnk = 1 Will get only the records with out duplicate
To solve Question 1 use the following query:
select name,dept,salary from emp e
where salary = (select max(salary)
from emp
where dept = e.dept
)
order by dept
This question is for how many years of experience candidates ?
For duplicates,
With CTE
(Select *, row_number() over (partition by dept,name,salary order by salary) as rnk from emp)
SELECT * from CTE where rnk = 1
Will get only the records with out duplicate