Oracle学习笔记20150818一些常见查询语句
2015-08-17 08:44
519 查看
(1)单行子查询用"=",多行子查询用"in".
(2)all的用法select * from emp where sal> all(select sal from where deptno=30).
(3)与all同样用法的还有any,只需注意其代表的意义.
(4)多列子查询可以用这种方法select * from emp where(deptno,job)=(select deptno,job from emp where ename='SMITH');
(5)null前面只能加is与is not;
(6)把前面的查询结果当做一个临时表对待
select t2.ename,t2.sal,myavg,t2 deptno from emp t2,(select avg(sal) myavg,deptno from emp group by deptno)t1 where t2.deptno=t1.deptno and t2.sal>t1.myavg;
查询每个大于本部门平均工资的员工.
(7)分析 select t2.ename,sal,t1.myavg,t2.deptno from emp t2,(select avg(sal) myavg,deptno from emp group by deptno) t1 where t2.deptno=t1.deptno and t2.sal>t1.myavg;
(8) select * from emp,(select max(sal) sal,deptno from emp group by deptno) t1 where emp.deptno=t1.deptno and emp.sal=t1.sal;
查询每个部门工资最高的人的信息
(9)select dept.dname,t1.deptno,t1.coun from dept,(select deptno,count(*) coun from emp group by deptno) t1 where dept.deptno=t1.deptno;
查询每个部门信息以及相应部门雇员总数
(2)all的用法select * from emp where sal> all(select sal from where deptno=30).
(3)与all同样用法的还有any,只需注意其代表的意义.
(4)多列子查询可以用这种方法select * from emp where(deptno,job)=(select deptno,job from emp where ename='SMITH');
(5)null前面只能加is与is not;
(6)把前面的查询结果当做一个临时表对待
select t2.ename,t2.sal,myavg,t2 deptno from emp t2,(select avg(sal) myavg,deptno from emp group by deptno)t1 where t2.deptno=t1.deptno and t2.sal>t1.myavg;
查询每个大于本部门平均工资的员工.
(7)分析 select t2.ename,sal,t1.myavg,t2.deptno from emp t2,(select avg(sal) myavg,deptno from emp group by deptno) t1 where t2.deptno=t1.deptno and t2.sal>t1.myavg;
(8) select * from emp,(select max(sal) sal,deptno from emp group by deptno) t1 where emp.deptno=t1.deptno and emp.sal=t1.sal;
查询每个部门工资最高的人的信息
(9)select dept.dname,t1.deptno,t1.coun from dept,(select deptno,count(*) coun from emp group by deptno) t1 where dept.deptno=t1.deptno;
查询每个部门信息以及相应部门雇员总数
相关文章推荐
- Oracle清理回收站的方法
- Oracle清理回收站的方法
- 解决Windows 7下安装Oracle 11g相关问题的方法
- Oracle 树操作(select…start with…connect by…prior)
- oracle 统计指定条件下所有表的行数
- Oracle对象表
- Oracle解析 xml 记录一下(未完待续)
- oracle11g 安装及plsql连接在win8 64位系统上
- 将Lomboz Eclipse 连接上 Oracle 11g
- ORACLE 10g 安装教程[图文]
- Java操作Oracle数据库自建工具库
- oracle10g安装时报"无法确定主机的IP地址时产生异常错误"
- ORACLE监听器 The listener supports no services 问题解决方法
- 在MAVEN仓库中添加ORACLE JDBC驱动
- Hibernate(Oracle) 报Source not found错误原因一
- Oracle PGA
- Linux Kernel Parameter config for Oracle
- oracle SGA
- oracle备份和升级数据库
- Oracle数据库临时总结-1