Chinaunix首页 | 论坛 | 博客
  • 博客访问: 555515
  • 博文数量: 43
  • 博客积分: 8000
  • 博客等级: 中将
  • 技术积分: 1510
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 15:07
文章分类

全部博文(43)

文章存档

2011年(1)

2009年(12)

2008年(30)

我的朋友

分类: Oracle

2008-05-25 17:22:25

select deptno,
  ename,
  sal,
row_number() over(partition by deptno order by sal desc) rn,
rank() over(partition by deptno order by sal desc) rank,
dense_rank() over(partition by deptno order by sal desc) dense_rank
 from emp
order by deptno,sal desc;
select deptno,
max(decode(dense_rank,1,sal)) sal1,
max(decode(dense_rank,2,sal)) sal2,
max(decode(dense_rank,3,sal)) sal3
from
( select deptno,sal,
 dense_rank() over(partition by deptno order by sal desc) dense_rank
from emp
)
group by deptno;
 
 
select port,activity
lead(activity) over(partition by port order by activity_date) nxt_activity,
activity_date,
lead(activity_date) over(partition by port order by activity_date) nxt_activity_date
from t;
阅读(928) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~