我试图从某些数据中提取百分位数但我得到每个百分位数的相同值。为什么呢?
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
答案 0 :(得分:1)
因为,对于由 percentile_cont 列组成的每一行,应返回多行,如果使用 GROUP BY ,则所有 percentile_cont 列将形成单个行提供的行 three_sixty_review_aid 具有唯一值。因此,如果three_sixty_review_aid列具有唯一值,则逐个表达式删除以获取由 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;