易截截图软件、单文件、免安装、纯绿色、仅160KB

ORACLE Top/Bottom N、First/Last、NTile

目录
==================================================================
1.带空值的排列
2.Top/Bottom N查询
3.First/Last排名查询
4.按层次查询
一、带空值的排列:
假如被排列的数据中含有空值呢?
SQL> select region_id, customer_id,
   2         sum(customer_sales) cust_sales,
   3         sum(sum(customer_sales)) over(partition by region_id) ran_total,
   4         rank() over(partition by region_id
   5                  order by sum(customer_sales) desc) rank
   6    from user_order
   7   group by region_id, customer_id;
REGION_ID CUSTOMER_ID CUST_SALES RAN_TOTAL       RANK
---------- ----------- ---------- ---------- ----------
         10          31               6238901          1
         10          26    1808949    6238901          2
         10          27    1322747    6238901          3
         10          30    1216858    6238901          4
         10          28 


相关文档:

oracle 数据管理

 一:
使用Profile对用户Session会话进行资源限制
--但是如果使用了连接池之类的东东,就会出些问题,比如前台连接不上之类的
--http://www.eygle.com/archives/2008/10/profile_session_limit.html
sqlplus "/ as sysdba"
SQL> show parameter resource
SQL> alter system set resource_limit= ......

ORACLE SAVE EXCEPTION 子句

今天在一个帖子里看到shiyiwan的回帖中提及到了两个自己以前没见过的概念,save exception和dml error logging。上网搜了搜相关内容,看了看大概明白意思,不过在实际运用中还是没怎么用过。保存下来,以后用的到的话方便查阅。
这一篇是关于save exception的,另外一篇dml error logging的参见如下链接
http://blog.csdn ......

ORACLE 游标和游标变量的区别

如何定义游标类型
TYPE ref_type_name IS REF CURSOR [RETURN return_type];
声明游标变量
cursor_name ref_type_name;
从技术底层看,两者是相同的。普通plsql cursor在定义时是“静态”的。而Ref cursors可以动态打开。
例如下面例子:
Declare
type rc is ref cursor;
cursor c is select * from dual ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号