码迷,mamicode.com
首页 > 数据库 > 详细

Oracle分析函数-等级函数

时间:2015-11-27 10:37:40      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

SELECT b.*,
RANK() OVER(PARTITION BY b.dname ORDER BY b.sal) AS rank_num,
Dense_rank() OVER(PARTITION BY b.dname ORDER BY b.sal) AS dence_rank,
MIN(sal) KEEP(dense_rank FIRST ORDER BY b.sal) OVER(PARTITION BY b.dname) AS first_val,
MAX(sal) KEEP(DENSE_rank LAST ORDER BY b.sal) OVER(PARTITION BY b.dname) AS last_val,
LAG(sal, 1, 0) OVER(PARTITION BY b.dname ORDER BY b.sal) AS pre_val,
LEAD(sal, 1, 0) OVER(PARTITION BY b.dname ORDER BY b.sal) AS following_val,
first_value(b.sal) OVER(PARTITION BY b.dname ORDER BY b.sal) AS first_val,
first_value(b.sal) OVER(PARTITION BY b.dname ORDER BY b.sal DESC) AS first_val_desc,
last_value(b.sal) OVER(PARTITION BY b.dname ORDER BY b.sal) AS last_val,
last_value(b.sal) OVER(PARTITION BY b.dname ORDER BY b.sal DESC) AS last_val_desc,
row_number() OVER(PARTITION BY b.dname ORDER BY b.sal) AS row_num
FROM B

技术分享

Oracle分析函数-等级函数

标签:

原文地址:http://www.cnblogs.com/tianyahaijiao/p/4999627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!