也许有很多种方法,这里只是书上学到的一种方法

with a as (
select grp_factor from (select distinct grp_factor from numbers where id < 10 order by grp_factor) t
where rownum <= 5) select b.id, a.grp_factor
from a cross apply(select id from (select id from numbers b where a.grp_factor = b.grp_factor order by id) t where rownum<=3)b --use v$sqlarea to find out your query by searching with key words. this might --take a little bit long.
select sql_id, sql_text from v$sqlarea where sql_text like '%cross apply%'; --copy the sql_id and place in the first place of parameters in the
--function "dbms_xplan.display_cursor" . in our case, it is 1gbpuv6zfq64s
select * from table(dbms_xplan.display_cursor('1gbpuv6zfq64s',null,'typical')); SQL_ID 1gbpuv6zfq64s, child number 0
-------------------------------------
with a as ( select grp_factor from (select distinct grp_factor from
numbers where id < 10 order by grp_factor) t where rownum <= 5)
select b.id, a.grp_factor from a cross apply(select id from (select id
from numbers b where a.grp_factor = b.grp_factor order by id) t where
rownum<=3)b Plan hash value: 3737636938 ------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100)| |
| 1 | NESTED LOOPS | | 1 | 26 | 2 (0)| 00:00:01 |
| 2 | VIEW | | 1 | 13 | 1 (0)| 00:00:01 |
|* 3 | COUNT STOPKEY | | | | | |
| 4 | VIEW | | 1 | 13 | 1 (0)| 00:00:01 |
|* 5 | SORT UNIQUE STOPKEY | | 1 | 26 | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID BATCHED| NUMBERS | 1 | 26 | 1 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | SYS_C009920 | 1 | | 1 (0)| 00:00:01 |
| 8 | VIEW | VW_LAT_A83890C2 | 1 | 13 | 1 (0)| 00:00:01 |
|* 9 | COUNT STOPKEY | | | | | |
| 10 | VIEW | | 1 | 13 | 1 (0)| 00:00:01 |
|* 11 | TABLE ACCESS BY INDEX ROWID | NUMBERS | 1 | 26 | 1 (0)| 00:00:01 |
| 12 | INDEX FULL SCAN | SYS_C009920 | 1 | | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id):
--------------------------------------------------- 3 - filter(ROWNUM<=5)
5 - filter(ROWNUM<=5)
7 - access("ID"<10)
9 - filter(ROWNUM<=3)
11 - filter("A"."GRP_FACTOR"="B"."GRP_FACTOR") SQL_ID 1gbpuv6zfq64s, child number 1
-------------------------------------
with a as ( select grp_factor from (select distinct grp_factor from
numbers where id < 10 order by grp_factor) t where rownum <= 5)
select b.id, a.grp_factor from a cross apply(select id from (select id
from numbers b where a.grp_factor = b.grp_factor order by id) t where
rownum<=3)b Plan hash value: 3737636938 ------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------

最新文章

  1. 文章转载利用border、transparent实现微风
  2. Git的简单使用教程
  3. 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&amp;合句(Complex Sentences、Compound Sentences)
  4. 用Supervisord管理Python进程
  5. JS获取浏览器可视区域的尺寸
  6. Monad
  7. Couldn&#39;t load libPassword from loader:NDK开发中C文件编译成cpu对应的so类库时,找不到类库报错的原因之一
  8. 4.4、Libgdx用法查询执行环境相关性
  9. 一篇文章学会springMVC(转)
  10. Python+PyCharm的一些基本设置:安装使用、注册码、显示行号、字体大小和快捷键等常用设置
  11. leetcode python最长回文子串
  12. dskinlite(uieasy mfc界面库)使用记录3:绘制动态元素(按钮控件通过隐藏方式修改图片显示)
  13. phpcms 手机门户配置注意事项
  14. Go 初体验 - 令人惊叹的语法 - defer.1 - 基本概念和用法
  15. VBA字符串处理大全
  16. python 最小二乘拟合,反卷积,卡方检验
  17. 可变,不可变类型和hash
  18. 盾牌第一至七季/全集The Shield迅雷下载
  19. 利用python的KMeans和PCA包实现聚类算法
  20. 【转】【WPF】WPF - MVVM - 如何将ComboBox的Selectchange事件binding到ViewModel

热门文章

  1. Careercup - Google面试题 - 5661939564806144
  2. 两个SVN仓库之间代码的转移
  3. 【BZOJ】【1520】【POI2006】Szk-Schools
  4. c++ 继承和组合的区别
  5. Slim - 超轻量级PHP Restful API构建框架
  6. [工作积累] bitfield
  7. 在线编辑器 (UBB, FCK)
  8. (转)Engineering Productivity
  9. Activity学习(三)——跳转传值
  10. 获取及管理Android 手机运营商及状态