代码之家  ›  专栏  ›  技术社区  ›  Letholdrus

postgresql percentile_cont为所有百分位数返回相同的值

  •  0
  • Letholdrus  · 技术社区  · 7 年前

    我试图从一些数据中提取百分位数,但每个百分位数的值是相同的。为什么?

    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
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Barbaros Özhan    7 年前

    因为,对于由 百分位数 列,如果 分组依据 全部已使用 百分位数 提供的列构成单行 三个审查援助 百分位数 柱:

    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