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:
(1) Find the highest paid employee who earns more than the average salary of all employees of his company.
(2) Find the highest paid employee who earns more than the average salary of all the employees of all the companies.
(3) Find all employees who earn more than the average salary of all employees of all the companies.
(4) Find all employees who earn more than the average salary of all employees of their company.
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:
(1) Find the highest paid employee who earns more than the average salary of all employees of his company.
(2) Find the highest paid employee who earns more than the average salary of all the employees of all the companies.
(3) Find all employees who earn more than the average salary of all employees of all the companies.
(4) Find all employees who earn more than the average salary of all employees of their company.