From: | PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | How do work tercile, percentile & funcion percentile_cont() ? |
Date: | 2020-04-22 08:00:49 |
Message-ID: | 1045753462.38287828.1587542449789.JavaMail.zimbra@meteo.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
From a table x(c1) containing 30 lines with integer values (column c1) from 1 to 30 :
SELECT percentile_cont(1./3) WITHIN GROUP (ORDER BY c1) FROM x ;
percentile_cont
------------------
10.6666666666667
(1 ligne)
SELECT percentile_cont(2./3) WITHIN GROUP (ORDER BY c1) FROM x ;
percentile_cont
------------------
20.3333333333333
(1 ligne)
If ordering,
the first 10 lines (c1 from 1 to 10) have ntile(3) OVER(ORDER BY c1) = 1,
the 10 following lines (c1 from 11 to 20) have ntile(3) OVER(ORDER BY c1) = 2,
the last 10 lines (c1 from 21 to 30) have ntile(3) OVER(ORDER BY c1) = 3.
So, I though it should be :
percentile_cont(1./3) = 10.5 (the arithmetic average between 10 et 11) and not 10.6666666666667
percentile_cont(2./3) = 20.5 (the arithmetic average between 20 et 21) and not 20.3333333333333
Thank in advance for explanation
----- Météo-France -----
PALAYRET JACQUES
DCSC/MBD
jacques(dot)palayret(at)meteo(dot)fr
Fixe : +33 561078319
From | Date | Subject | |
---|---|---|---|
Next Message | PALAYRET Jacques | 2020-04-22 08:15:26 | Re: How do work tercile, percentile & funcion percentile_cont() ? |
Previous Message | Laurenz Albe | 2020-04-22 07:19:05 | Re: how to slow down parts of Pg |