Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Sunday, March 3, 2013

Using Correlated Subqueries


Find all employees who earn more than the average salary in their department.




SELECT last_name, salary, department_id
FROM employees outer
WHERE salary >
                      (SELECT AVG(salary)
                       FROM employees
                       WHERE department_id =  outer.department_id) ;


Each time a row from the outer query is processed, the inner query is evaluated.

No comments:

Post a Comment