我正在尝试编写一个查询来查找 AdventureWorks 数据库中男性和女性员工的平均工资率
我写了这个(如下),但我没有得到想要的结果:
with sub as
(
select
emp.Gender, emp.VacationHours, pay.Rate
from
HumanResources.Employee emp, HumanResources.EmployeePayHistory pay
where
emp.BusinessEntityID = pay.BusinessEntityID
)
select
sub.Gender,
avg(sub.VacationHours) as vac_hours,
avg(sub.Rate) as rate
from
sub
group by
sub.Gender, Rate;
我正在尝试这样做,以便更好地了解函数的工作原理