易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

AIX Oracle RAC 升级到10.2.0.4.0要特别注意的问题

AIX Oracle RAC 升级到10.2.0.4.0过程有如下报错(直接升级到10.2.0.4不需要应用Patch:6160398):
 root@bwgl_db2:/u01/app/oracle/crs_1/bin# /u01/app/oracle/crs_1/install/root102.sh
Error : Please change the CRS_ORACLE_USER id <oracle> to have the following OS capabilities :
  <CAP_BYP ......

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 ......

oracle 10g 控制台启动端口修改

例如我在oracle10g里配置了2个数据库xljc和xldb,期控制太浏览器种启动分别为:xljc在浏览器中输入 http://zhang:5500/em xldb在浏览器中输入 http://zhang:1158/em如果忘记了启动端口号,可以查询文件
例如我在oracle10g里配置了2个数据库xljc和xldb,期控制太浏览器种启动分别为:xljc在浏览器中输入 http://zhang:5500/em
x ......

ORACLE 学习

一、安装(略)
      服务器端
      1、windows:(略)
      2、linux:待续...
      客户端
         待续...
     --包括配置--
二、登陆
......

Oracle时间类型数据为0的bug

应用数据库中记录中date列莫名其妙的出现了几个值为0000-00-00的数据。
更可怕的是如果将这样的记录进行读取成为varchar2后再to_date转换回去就会报错。
问题无从查起,只说一下最终同事搜索到的连接结果:http://www.hellodba.com/Doc/oracle_date_zero_bug.htm
看来的确是oracle的一个bug。
另外需要注意的是,在使用 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号