PostgreSQL percentile_cont return 所有百分位数的值相同

PostgreSQL percentile_cont return same value for all percentiles

我正在尝试从某些数据中提取百分位数,但每个百分位数的值都相同。为什么?

SELECT three_sixty_review_aid, 
percentile_cont(0.95) within group (order by questions_combined asc) as p_95,
percentile_cont(0.75) within group (order by questions_combined asc) as p_75,
percentile_cont(0.5) within group (order by questions_combined asc) as p_50,
percentile_cont(0.25) within group (order by questions_combined asc) as p_25,
percentile_cont(0.1) within group (order by questions_combined asc) as p_10,
percentile_cont(0.05) within group (order by questions_combined asc) as p_05
FROM reviews_threesixty.peer_review_avg_combined_per_review
 group by three_sixty_review_aid

因为,如果使用GROUP BY,则由percentile_cont列组成的每一行应该返回多行,所有 percentile_cont 列形成单行,前提是 three_sixty_review_aid 具有唯一值。因此,如果 three_sixty_review_aid 列具有唯一值,则删除 group by expression 以获得由 percentile_cont 列组成的行的不同值:

SELECT  percentile_cont(0.95) within group (order by questions_combined asc) as p_95,
        percentile_cont(0.75) within group (order by questions_combined asc) as p_75,
        percentile_cont(0.5) within group (order by questions_combined asc) as p_50,
        percentile_cont(0.25) within group (order by questions_combined asc) as p_25,
        percentile_cont(0.1) within group (order by questions_combined asc) as p_10,
        percentile_cont(0.05) within group (order by questions_combined asc) as p_05
   FROM reviews_threesixty.peer_review_avg_combined_per_review;

SQL Fiddle Demo