1.

The employee information in a company is stored in the relationEmployee (name, sex, salary, deptName)Consider the following SQL queryselect 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(A) the average salary is more than the average salary in the company(B) the average salary of male employees is more than the average salary of all male employees in the company(C) the average salary of male employees is more than the average salary of employees in the same department(D) the average salary of male employees is more than the average salary in the company

Answer» Answer: (D)
Explanation: In this SQL query, we have

select deptName --------------- Select the department namefrom Employee ---------------- From the database of employeeswhere sex = 'M' --------------- Where sex is male (M)group by deptName ------------- Group by the name of the departmenthaving avg (salary) > (select avg (salary) from Employee) ----- Having the average salary greater than the average salary of all employees in the organization.

So, this query would return the name of all departments in which the average salary of male employees is greater than the average salary of all employees in the company.

Hence, D is the correct choice.



Discussion

No Comment Found

Related InterviewSolutions