提高第10部门最低工资雇员1%的工资
我的解决方案
update emp set sal = sal + (sal* 1/100)
where
sal = (select min(sal) from emp2 where deptno = 10)-1行更新
但正确的解决办法是
update emp set sal = sal + (sal* 1/100)
where
sal = (select min(sal) from emp2 where deptno = 10)
and deptno=10-1行更新
这里的问题是为什么我的解决方案是错误的。
1)从emp2中找出谁的sal在deptno 10选择min(sal)中最低,其中deptno = 10--
2)提高10部门最低工资的员工1%的薪资,因此,更新emp设置sal = sal + ( sal * 1/100),其中sal=(选择emp2 (Sal),其中deptno = 10)
发布于 2014-04-06 06:16:08
如果在主查询中没有该deptno=10条件,您将更新所有只匹配薪资金额的员工。这就是为什么正确的答案对子查询和主查询都有这个条件的原因。
https://stackoverflow.com/questions/22890632
复制相似问题