分页查询练习
1. 查询工资最高的3名员工信息
select t1.* from
(select * from employees order by salary desc) t1
where rownum<=3
2. 查询工资排名第5到第10的员工信息
select t2.* from
(select t1.*,rownum rn from
(select * from employees order by salary desc)t1
where rownum<=10)t2
where rn >= 5
3. 查询first_name是以大写D开头的第3到第5个员工信息
select t2.* from
(select t1.*,rownum rn from
(select * from employees where first_name like 'D%')t1
where rownum<=5)t2
where rn >= 3
子查询练习
1. 显示工资比’Allan’(first_name)高的所有员工的姓名和工资
select first_name,salary from employees where salary>
(select salary from employees where first_name='Allan')
2. 显示与’Allan’(first_name)从事相同工作的员工的详细信息
select * from employees where job_id=
(select job_id from employees where first_name='Allan')
3. 查询工资大于本部门平均工资的员工基本信息
(1)select e1.employee_id,e1.last_name,e1.salary
from employees e1 where e1.salary>
(select avg(salary) from employees e2 where e2.d
ocacle数据库相关练习二(分页、子查询、表连接)
最新推荐文章于 2022-08-11 09:55:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)