关于oracle的问题,有emp,dept,salgrade 三个表。完成以下问题。
发布网友
发布时间:2022-04-12 21:46
我来回答
共2个回答
热心网友
时间:2022-04-12 23:15
1.显示部门号为10 的部门名、员工名和工资
select deptno, ename, sal
from emp
where deptno = 10;
2. 工资级别是什么?在表中怎么体现?
select ename, sal
from emp;
3. 显示员工BLAKE 的上级领导的姓名
select e1.ename
from emp e1
where e1.empno = (select e2.mgr
from emp e2
where e2.ename = 'BLAKE');
4.显示与scott同一部门的所有员工
select e1.*
from emp e1
where e1.deptno = (select e2.deptno
from emp e2
where e2.ename = 'scott');
5.显示工资比部门 30 的所有员工的工资高的员工的姓名、工资和部门号
select e1.ename, e1.sal, e1.deptno
from emp e1
where e1.sal >all (select e2.sal
from emp e2
where e2.deptno = 30);
6.查询与smith 部门和岗位完全相同的所有雇员
select e1.*
from emp e1
where e1.dept = (select e2.dept from emp e2 where e2.ename = 'smith')
and e1.job = (select e3.job from emp e3 where e3.ename = 'smith')
7.显示高于部门平均工资的员工的信息
select e1.*
from emp e1
where e1.sal > (select avg(e2.sal)
from emp e2
where e1.deptno = e2.deptno
group by e2.deptno);
8.查询部门工资总和高于员工工资总和1/3的部门名及工资总和
select e1.deptno, sum(e1.sal)
from emp e1
group by e1.deptno
having sum(e1.sal) > (select sum(e2.sal) / 3.0
from emp e2);
热心网友
时间:2022-04-13 00:33
1. select ename,dname,sal from emp natural join dept;
2. select ename,sal,grade from emp join salgrade on (emp.sal >=losal and emp.sal<=hisal);
3. select ename from emp where empno=(select MGR from emp where ename='BLAKE');
4. select * from emp where deptno=(select deptno from emp where ename='SCOTT');
5. select ename,sal,deptno from emp where sal > (select max(sal) from emp where deptno=30);
6. select * from emp where (deptno,job)=(select deptno,job from emp where ename='SMITH') and ename<>'SMITH';
7. select * from emp join (select deptno,avg(sal) avgsal from emp group by deptno) t on emp.deptno=t.deptno and emp.sal>t.avgsal;
8. select dname,sum(sal) from emp join dept on emp.deptno=dept.deptno group by dname having sum(sal) > (select sum(sal) from emp)/3;