练习:
drop table Employee;
create table Employee(
id number primary key,
uName varchar2(32) ,
dept_id int ,
salary number
);
insert into Employee (id ,uName, dept_id, salary ) values (1,'ZhangShan',null, 10000);
insert into Employee (id ,uName, dept_id, salary ) values (2,'LiShi',1, 8000);
insert into Employee (id ,uName, dept_id, salary ) values (3,'WangWu',2, 6000);
insert into Employee (id ,uName, dept_id, salary ) values (4,'ZhaoLiu',3, 4000);
insert into Employee (id ,uName, dept_id, salary ) values (5,'QianQi',4, 2000);
要求:
<1>使用自连接查出表中员工的姓名及其领导的姓名?
select a.ename,b.ename
from emp a inner join emp b
on a.mgr = b.empno ;
<2>使用外连接查出表中员工的姓名及其领导的姓名?
select a.ename,b.ename
from emp a inner join emp b
on a.mgr =b.empno(+) ;
<3> 用一条SQL语句实现
给 2 部门员工将工资降至原来 80%
给 4 部门员工将工资减至原来 70%
给 1 3 5 部门员工将工资涨至原来 150%
update emp set sal=decode(deptno,10,0.8*sal,20,0.7*sal,30,1.5*sal) ;
&nbs