我可以在oracle数据库中使用公用表表达式进行更新吗?
我在ORA-00928: missing SELECT keyword尝试时遇到错误:
ORA-00928: missing SELECT keyword
with average as (SELECT avg(salary) FROM instructor) update instructor set salary = case when salary <= average then salary * 1.05 else salary * 1.03 end
由于average salary仅是一个 标量值, 您可以做
average salary
update instructor set salary = case when salary <= (select avg(t.salary) from instructor t) then salary * 1.05 else salary * 1.03 end
在这种情况下,Oracle首先 计算平均值 (例如1234.4567),然后执行 更新 。
1234.4567