关于rollup的简单用法和层次查询
来源:互联网 发布:软件用户体验问卷 编辑:程序博客网 时间:2024/06/16 03:29
select t.deptno,t.job,sum(sal) from emp t group by rollup(t.deptno,t.job);
等价于
select t.deptno,t.job,sum(sal) from emp t group by t.deptno,t.job+select t.deptno,sum(sal) from emp t group by t.deptno+select sum(sal) from emp t ;
group by rollup(a,b) = group by a,b + group by a + group by null
break on deptno skip 2
每个部门显示一次,不同部门相隔2行.
层次查询;
--使用这种写法可以只查一遍emp表,既可以知道员工号和他的老板号,不需要自连接,因为自连接在大表查询中效率较慢.select level, t.* from emp t --使用上一层的 员工号 = 老板号connect by prior t.empno = t.mgr --描述从树的哪个节点出发,下面语句是从老板号为空的节点也就是KING出发,查询树的结构,这个level就是树的深度,是个伪列. start with t.mgr is null order by level;
阅读全文
0 0
- 关于rollup的简单用法和层次查询
- cube和rollup的用法
- Oracle Grouping、Rollup 的简单用法
- Oracle Grouping、Rollup 的简单用法
- Oracle Grouping、Rollup 的简单用法
- SQL中CUBE和ROLLUP的用法
- oracle中rollup和cube的用法
- oracle中rollup和cube的用法
- Oracle层次查询的基本用法
- 带all、cube和rollup的Group By查询
- Oracle ROLLUP和CUBE 用法
- Oracle ROLLUP和CUBE 用法
- oracle Rollup 和 Cube用法
- Oracle ROLLUP和CUBE 用法
- Oracle ROLLUP和CUBE 用法
- ROLLUP、CUBE 和GROUPING用法 .
- oracle Rollup 和 Cube用法
- Oracle ROLLUP和CUBE 用法
- 作业作业
- 第二章 程序的基本结构
- Spring AOP的使用
- [练习]Hello World
- linux命令
- 关于rollup的简单用法和层次查询
- setNeedsLayout 和 layoutIfNeeded
- Linux系统的IP配置
- 【Python-3.5】matplotlib绘制气温折线图
- Java day7
- mybaits错误解决:There is no getter for property named '' in class 'java.lang.String'
- 【正则表达式】简单入门介绍
- 阿里云服务器如何打开端口、MySQL Error2003解决办法
- JAVA:2006年培养学员8万人,每年增长25%,请问按照次增长速度,到哪一年培养学员人数将达到20万人?while do while for语句