Chinaunix首页 | 论坛 | 博客
  • 博客访问: 925371
  • 博文数量: 358
  • 博客积分: 8185
  • 博客等级: 中将
  • 技术积分: 3751
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:27
个人简介

The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.

文章分类

全部博文(358)

文章存档

2012年(8)

2011年(18)

2010年(50)

2009年(218)

2008年(64)

我的朋友

分类: Oracle

2008-10-23 18:06:59

 
 
 
select 
RANK() over (order by sal desc),
rank() over (partition by deptno order by sal desc),
a.empno,a.deptno,
a.sal,
lag(sal,1) over (partition by deptno order by sal desc) - sal
 from emp a order by deptno,sal desc;
 
 
 RANK()OVER(ORDERBYSALDESC) RANK()OVER(PARTITIONBYDEPTNOORDERBYSALDESC)      EMPNO     DEPTNO        SAL LAG(SAL,1)OVER(PARTITIONBYDEPTNOORDERBYSALDESC)-SAL
-------------------------- ------------------------------------------- ---------- ---------- ---------- ---------------------------------------------------
                         2                                           1       7839         10       5000
                         7                                           2       7782         10       2450                                        2550
                         9                                           3       7934         10       1300                                        1150
                         3                                           1       7902         20       3000
                         3                                           1       7788         20       3000                                           0
                         5                                           3       7566         20       2975                                          25
                        12                                           4       7876         20       1100                                        1875
                        15                                           5       7369         20        800                                         300
                         1                                           1       7890         30       5600
                         6                                           2       7698         30       2850                                        2750
                         8                                           3       7844         30       1500                                        1350
                        10                                           4       7521         30       1250                                         250
                        10                                           4       7654         30       1250                                           0
                        12                                           6       7499         30       1100                                         150
                        14                                           7       7900         30        950                                         150
 
 
 
阅读(1854) | 评论(0) | 转发(0) |
0

上一篇:PL SQL

下一篇:Basic Sql

给主人留下些什么吧!~~