-1
我想要显示所有员工的平均工资高于平均水平的员工编号,姓氏和薪水,并按升序排列结果。但是,我已经收到错误'组功能不允许在这里'。我应该如何写它?将平均函数放在where子句中
select employee_id,last_name,salary from employees
where salary > avg(salary)
order by salary;
我想要显示所有员工的平均工资高于平均水平的员工编号,姓氏和薪水,并按升序排列结果。但是,我已经收到错误'组功能不允许在这里'。我应该如何写它?将平均函数放在where子句中
select employee_id,last_name,salary from employees
where salary > avg(salary)
order by salary;
select a.employee_id,a.last_name,a.salary from employees a
where a.salary > (select avg(b.salary) from employees b)
order by a.salary;
使用AVG() OVER()
窗口集合函数
select * from
(
select employee_id,last_name,salary,avg(salary)over() as avg_salary from employees
) e
where salary > avg_salary
order by salary;
难道我们不需要()周围的子查询?我刚刚提交了一个编辑,@ luisteijon。 – codeforester
此脚本得到错误'缺少表达' –
尝试编辑@codeforester –