Multiple choice

The employee information in a company is stored in the relation Employee (name, sex, salary, deptName) Consider the following SQL query select deptname from Employee where sex='M' group by deptName having avg (salary)> (select avg(salary)from Employee) It returns the names of the department in which

  1. the average salary is more than the average salary in the company

  2. the average salary of male employees is more than the average salary of all male employees in the company

  3. the average salary of male employees is more than the average salary of employees in the same department

  4. the average salary of male employees is more than the average salary in the company

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

“Select average (salary) from employee” selects average salary of the company. So the query returns the names of all the male employees of all the departments whose average salary is more than the average salary in the company.