Sql 如何解决此错误-ORA-22818:不允许使用子查询表达式?

Sql 如何解决此错误-ORA-22818:不允许使用子查询表达式?,sql,oracle,Sql,Oracle,但它显示了一个错误: 此处不允许使用子查询表达式 您知道如何解决此错误吗?左联接返回每个部门最低和最高工资的派生表(也称为内联视图): SELECT first_name, (select min(salary) from hr.employees where department_id = 103), (select max(salary) from hr.employees where department_id = 103) from hr.employees where hr.emplo

但它显示了一个错误:

此处不允许使用子查询表达式

您知道如何解决此错误吗?

左联接
返回每个部门最低和最高工资的派生表(也称为内联视图):

SELECT first_name, (select min(salary) from hr.employees where department_id = 103), (select max(salary) from hr.employees where department_id = 103)
from hr.employees where hr.employees.department_id = 103;

改为尝试左联接。@Mary您的查询是有效的Oracle语法,在我的数据库上运行良好。我假设您得到错误是因为您在一些不寻常的上下文中使用查询,比如作为物化视图的一部分。你能编辑你的问题并添加一些细节吗?@Mary,对不起,我不知道Oracle的日期/时间功能。(我从来没有用过甲骨文。)其他有相同部门id 103的员工?您可以让子查询返回count(*)。要获得更好的帮助,请在子查询中单独提问。count(*)。在主选择框中选择大小写。
SELECT e.first_name,
       e2.min_sal,
       e2.max_sal
from hr.employees e
left join (select department_id, min(salary) min_sal, max(salary) max_sal
           from hr.employees
           group by department_id) e2
  on e.department_id = e2.department_id
where e.department_id = 103;