I am practising Oracle Subqueries.. (I am new to Oracle.)
Question: Find the Highest Earning Employee in each Department?
My query below works (BUT I feel its not that good, even though I get the correct result )
select e.deptid, e.name, e.salary
from employee e
where e.salary = (select max(salary)
from employee b
where b.deptid = e.deptid )
Is there another easy way? (Using inner joins or some other way?)
And I also am wondering: When exactly do we have to use Inner joins instead of using SubQueries? When exactly do we have to use SubQueries instead of Inner joins?