编写两条SQL语句,高手请进

来源:百度知道 编辑:UC知道 时间:2024/05/12 14:00:06
有两个表:
一个是EMP表(员工表),字段id,name,salary,age,...,info
另一个是DEP表(部门表),字段id,name,...info
1.查出某部门中低于400月薪(salary)的员工们的平均工资。
2.把低于400月薪员工们的工资上调10%。
题意大概如此,具体的记不清了。
第二个问也可能是:
2.把某部门低于400月薪员工们的工资上调10%

把全体部门低于400月薪员工们的工资上调10%

1.select AVG(e.salary) from EMP e, DEP d where e.depid=d.id and e.salary<400 and d.id=xxx
其中xxx就是DEP的id,假定emp表中有个depid字段,表示员工所属DEP
2. update EMP set salary=salary*1.10 where salary<400

select avg(salary) as a from emp where did=1 and salary<400

update emp set salary=salary*1.1 where salary<400

did 是员工的部门id