公司中的员工信息存储在关系中
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)男性员工的平均工资高于公司所有男性员工的平均工资
(三)男性员工平均工资高于同部门员工平均工资
(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 是正确的选择。
如果您发现上面的帖子有任何错误,请在下面发表评论。
这个问题的测验