Analyzer explains what need to do.
the first SQL looks terse, but the pct will always equal 1.
change to SQL 2, note the join relationship.
update employees e1
set pct = (select RATIO_TO_REPORT(salary) OVER () AS rr
from employees e2
WHERE e1.employee_id = e2.employee_id
)
WHERE job_id = 'PU_CLERK';
-->
update employees e1
set pct = (select aaa.rr from (select employee_id, rowid, RATIO_TO_REPORT(salary) OVER () AS rr
from employees
WHERE job_id = 'PU_CLERK') aaa
where e1.employee_id = aaa.employee_id
)
WHERE job_id = 'PU_CLERK';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17739/viewspace-803736/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/17739/viewspace-803736/