PostgreSQL 的 分布函数 cume_dist

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

posted @ 2012-09-06 09:58  健哥的数据花园  阅读(559)  评论(0编辑  收藏  举报