PostgreSQL的window函数整理(6)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-17 09:42 点击:次
3 | sales | 4 | 4800 | 2007-08-08
(11 rows)
postgres=# select percent_rank() over(partition by depname order by salary desc),* from empsalary;
percent_rank | depname | empno | salary | enroll_date
-------------------+-----------+-------+--------+-------------
0 | develop | 8 | 6000 | 2006-10-01
0.25 | develop | 10 | 5200 | 2007-08-01
0.25 | develop | 11 | 5200 | 2007-08-15
0.75 | develop | 9 | 4500 | 2008-01-01
1 | develop | 7 | 4200 | 2008-01-01
0 | personnel | 2 | 3900 | 2006-12-23
1 | personnel | 5 | 3500 | 2007-12-10
0 | sales | 6 | 5500 | 2007-01-02
0.333333333333333 | sales | 1 | 5000 | 2006-10-01
0.666666666666667 | sales | 3 | 4800 | 2007-08-01
0.666666666666667 | sales | 4 | 4800 | 2007-08-08
(11 rows)
postgres=# select cume_dist()over(partition by depname order by salary desc),* from empsalary; www.2cto.com
cume_dist | depname | empno | salary | enroll_date
-----------+-----------+-------+--------+-------------
0.2 | develop | 8 | 6000 | 2006-10-01
0.6 | develop | 10 | 5200 | 2007-08-01
0.6 | develop | 11 | 5200 | 2007-08-15
0.8 | develop | 9 | 4500 | 2008-01-01
1 | develop | 7 | 4200 | 2008-01-01
0.5 | personnel | 2 | 3900 | 2006-12-23
1 | personnel | 5 | 3500 | 2007-12-10
0.25 | sales | 6 | 5500 | 2007-01-02
0.5 | sales | 1 | 5000 | 2006-10-01
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>