大门|大门-CS-2004 |问题53

公司中的员工信息存储在关系中

null
Employee (name, sex, salary, deptName)

考虑下面的SQL查询

select deptName
       from Employee
       where sex = 'M'
       group by deptName
       having avg (salary) > (select avg (salary) from Employee)

它返回所属部门的名称 (A) 平均工资高于公司的平均工资 (B) 男性员工的平均工资高于公司所有男性员工的平均工资 (C) 男性员工的平均工资高于同一部门员工的平均工资

(D) 男性员工的平均工资高于公司的平均工资 答复: (D) 说明: 在这个SQL查询中,我们有

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

因此,这个查询将返回所有部门的名称,其中男性员工的平均工资高于公司所有员工的平均工资。

因此,D是正确的选择。

如果你在上面的帖子中发现任何错误,请在下面发表评论。 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享