Consider the following relation:
Works(emp_name, company_name,salary)
Here,emp name is primary key.
Consider the following SQL query
Select emp name
From works T
where salary > (select avg(salary)
from works S
where T. company name =
S. company name)
The above query is for following:
- Find the highest paid employee who earns more than the average salary of all employees of his company.
- Find the highest paid employee who earns more than the average salary of all the employees of all the companies.
- Find all employees who earn more than the average salary of all employees all the companies.
- Find all employees who earn more than the average salary of all employees of their company.