Inline View in SQL

Posted by Ij under Oracle category on | Points: 40 | Views : 913
When you use SQL Subquery in From clause of the select statement it is called INLINE view

SELECT a.last_name, a.salary, a.department_id, b.maxsal
FROM employees a,
( SELECT department_id, max(salary) maxsal
FROM employees
GROUP BY department_id ) b
WHERE a.department_id = b.department_id
AND a.salary = b.maxsal;

The above query display the employees who earn the highest salary in each department.

Comments or Responses

Login to post response