Oraclel练习题
巡山小妖精
885次浏览
2020年07月29日 11:43
最佳经验
本文由作者推荐
向量混合积-衅怎么读音
select * from emp;
2.查询emp表中ename,job,sal几列,其中sal列在结果集中已别名salary查询
select ename,job,sal salary from emp;
3.查询emp表中deptno,ename,年工资,并将年工资命名别名total salary
select deptno,ename,12*sal "total salary" from emp;
4.查询emp表结构 在命令窗口输入
desc emp;
5.查询emp表中雇员号,雇员的名字,工作岗位,入职日期
select empno,ename,job,hiredate from emp;
6.查询员工表中部门编号,重复的部门只查询一次
select distinct deptno from emp;
7.在结果集中雇员名和工作岗位相连用"空格都号空格"分隔,并将列表标题查询为Employee and Title--别名
select ename ||' ' ||from emp e)
where rank < 3;
--26. 查询平均工资最高的部门信息()
--步骤1:求每个部门的平均工资:
select avg(sal) avgsal, deptno from emp group by deptno;
--步骤2:求最高的平均工资:
select max(avgsal) ,deptno from emp group by deptno;
--步骤3:求平均工资最高的部门信息,连接步骤1 产生的临时表与真实表dept:
select d.*, avgsal
from dept d, (select avg(sal) avgsal, deptno from emp group by deptno) se
where avgsal = (select max(avg(sal)) from emp group by deptno)
and =
----------27. 查询大于各部门总工资的平均值的部门信息
--步骤1:求每个部门总工资
select sum(sal) sumsal, deptno from emp group by deptno;
--步骤2:求每个部门总工资平均值
select avg(sum(sal)) from emp group by deptno;
--步骤3:求大于总工资平均值的部门信息,连接步骤1 产生的临时表与真实表dept:
select d.*, sumsal
from dept d, (select sum(sal) sumsal, deptno from emp group by deptno) se
where sumsal > (select avg(sum(sal)) from emp group by deptno)
and =
---28. 查询大于各部门总工资的平均值的部门下的员工信息(考察知识点:子查询,组函数,连接查询)
select e.*, sumsal
from emp e, (select sum(sal) sumsal, deptno from emp group by deptno) se
where sumsal > (select avg(sum(sal)) from emp group by deptno)
and =
-- 这个题目呢,我们分析的时候是这样的,我们查找出来每个部门的总工资的平均工资,
-- 然后再查找出来每个部门的总工资,比较一下,然后根据部门号相等,就能算出来了
--29. 查询没有员工的部门信息
select d.*
from dept d
left join emp e
on ( = )
where empno is null;
30. 查询用户(users 表)huxz 所下所有订单编号,下单日期,总价格(orders 表),并包括订单中的商品数量(orderitem 表),名称(product 表),价格(product 表)
31. 查询100001 号商品被哪些顾客(users 表)购买过,下单日期(orders 表),每人购买的数量(orderitem 表),购买时的价格(product 表)
32. 查询出哪些商品从未被订购过
33. 查询出被订购过2 次以上的商品信息
Person p=new Student();`
List