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

oracle keep(first/last)


 先看一段ORACLE官方文档
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/analysis.htm#25806:
FIRST/LAST Functions
The FIRST/LAST aggregate functions allow you to return the result of an aggregate applied over a set of rows that rank as the first or last with respect to a given order specification. FIRST/LAST lets you order on column A but return an result of an aggregate applied on column B. This is valuable because it avoids the need for a self-join or subquery, thus improving performance. These functions begin with a tiebreaker function, which is a regular aggregate function (MIN, MAX, SUM, AVG, COUNT, VARIANCE, STDDEV) that produces the return value. The tiebreaker function is performed on the set rows (1 or more rows) that rank as first or last respect to the order specification to return a single value.
To specify the ordering used within each group, the FIRST/LAST functions add a new clause starting with the word KEEP.
大意是说FIRST/LAST函数按照某个字段排序后取得第一行或者最后一行,FIRST/LAST聚集函数可以按A列排序,B列聚集,避免了自连接和子查询.分组聚合函数(min,max....)位于FIRST/LAST函数之前产生多行结果集,并且按照排序返回FIRST/LAST单个值.
要指定在每个组的顺序,FIRST/LAST函数之前加上以关键字KEEP开始即可
FIRST/LAST Syntax
These functions have the following syntax:
aggregate_function KEEP
( DENSE_RANK LAST ORDER BY
expr [ DESC | ASC ] [NULLS { FIRST | LAST }]
 [, expr [ DESC | ASC ] [NULLS { FIRST | LAST }]]...)
[OVER query_partitioning_clause]
Note that the ORDER BY clause can take multiple expressions.请注意在ORDER BY子句可以采取多种表现形式
Returns the row ranked first using DENSE_RANK   
2种取值:
DENSE_RANK FIRST
DENSE_RANK LAST
在keep (DENSE_RANK first ORDER BY sl) 结果集中再取max、min的例子。
例子如下:oracle分析函数中,keep and over的区别
公司部门中入厂时间最早的员工的薪水最小的是多少
SQL>SELECT deptno,ename,empno,sal,
MIN(sal) KEEP (dense_rank FIRST ORDER BY hiredate) over (PARTITION


相关文档:

如何编写oracle存储过程

在我的上一个银行项目中,我接到编写ORACLE存储过程的任务,我是程序员,脑袋里只有一些如何使用CALLABLE接口调用存储过程的经验,一时不知如何下手,我查阅了一些资料,通过实践发现编写ORACLE存储过程是非常不容易的工作,即使上路以后,调试和验证非常麻烦。简单地讲,Oracle存储过程就是存储在Oracle数据库中的一个程序 ......

Oracle学习笔记:linux下启停Oracle


1. linux下启动oracle
su - oracle
sqlplus /nolog
conn /as sysdba
startup
exit
lsnrctl start
exit
2. linux下关闭oracle
su - oracle
sqlplus /nolog
conn /as sysdba
shutdown immediate
exit
lsnrctl stop
exit
3、启动监听器
oracle@suse92:~> lsnrctl start
4、停止监听器
oracle@suse92:~ ......

在Oracle 中查询某个字段存在于哪几个表 (转)

如果查询整库的话得以DBA权限查询数据字典dba_tab_columns
非DBA用户只能查看自己有读取权限的表
可以这样写查询
select owner, table_name
from dba_tab_columns
where lower(column_name)='firstname';
查询出哪些表包含firstname字段以及这些表属于哪个用户
注:dba_tab_columns是一个属于SYS用户的一个View ......

ORACLE 的补丁下载地址 (转)

oracle补丁下载
关键字: oracle
9.2.0.4  = 3095277
9.2.0.5  = 3501955
9.2.0.6  = 3948480
9.2.0.7  = 4163445
9.2.0.8  = 4547809(9i最终)
10.1.0.3 = 3761843
10.1.0.4 = 4163362
10.1.0.5 = 4505133
10.2.0.2 = 4547817
10.2.0.3 = 5337014
10.2.0.4 = 6810189
下 ......

oracle 多表删除 同时删除多表中关联数据

oracle 多表删除 同时删除多表中关联数据
2009-04-27 14:40
1、从数据表t1中把那些id值在数据表t2里有匹配的记录全删除掉
DELETE t1 from t1,t2 WHERE t1.id=t2.id    或DELETE from t1 USING t1,t2 WHERE t1.id=t2.id
2、从数据表t1里在数据表t2里没有匹配的记录查找出来并删除掉
DELETE t1 from t1 L ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号