且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PostgreSQL 的 分布函数 cume_dist

更新时间:2022-09-27 14:52:40

create table a7(id integer, value integer);

insert into a7 values(1,100);

insert into a7 values(2,200);

insert into a7 values(3,300);

insert into a7 values(4,400);

insert into a7 values(5,500);

 

select id, value, cume_dist() over (order by id) as percent from a7;

1   100   0.2

2   200   0.4

3   300   0.6

4   400   0.8

5   500   1

本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/06/2672935.html,如需转载请自行联系原作者