我在部门内选择高于平均水平的工资
SELECT employee_id, first_name|| ' ' ||last_name as Name, salary, department_id
FROM EMPLOYEES o
WHERE SALARY >
(SELECT AVG(salary) FROM EMPLOYEES i
WHERE i.department_id=o.department_id);
如何在不使用子查询的情况下在PLSQL中重写此查询?
答案 0 :(得分:0)
我不知道你是否想要代码,但首先,我告诉你需要采取的步骤。
- Create a cursor for the main query
- Create a loop to navigate that cursor
- Execute the select avg and save the result in a variable.
- Make an IF to compare
- Output / save the result