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
相关文档:
一:
使用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= ......
CREATE OR REPLACE PROCEDURE sendemailtest
(mailmsg IN Varchar2)
IS
--using mail server to send email.
mailconn UTL_SMTP.connection;
mailhost & ......
记得以前上OCP课程的时候那个老师教我们使用PROFILE来限制用户的一些操作,那个时候估计是老师偷懒吧,所有实验都是通过OEM的形式来操作,根本不会涉及到命令行。
平时在学习ORACLE的过程中好像也很少碰到关于PROFILE的问题,今天逛一个朋友的BLOG的时候发现这篇文章,觉得挺好的,内容不多,简洁明了,好歹也算是个命令行 ......
目录
======================================================
1.使用rownum为记录排名
2.使用分析函数来为记录排名
3.使用分析函数为记录进行分组排名
一、使用rownum为记录排名:
【1】测试环境:
SQL> desc user_order;
Name   ......