ocacle数据库相关练习二(分页、子查询、表连接)

本文介绍了如何在Oracle数据库中进行分页查询、使用子查询优化数据检索以及如何执行复杂的表连接操作。这些技巧对于数据库管理和Java应用的数据访问至关重要。
摘要由CSDN通过智能技术生成
分页查询练习
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
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值