On 2020-04-22 10:00:49 +0200, PALAYRET Jacques wrote: > 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) Think of the 30 values as points in a graph: The x values run from 0 to 29, the y values are your values. The points are connected with straight lines. Since your y values just increase by 1 you have a straight line from (0, 1) to (29, 30) Then percentile_cont(1./3) is the value y value 1/3 along that line and percentile_cont(2./3) is the y value 2/3 along that line. So you need to find the y values corresponding to 29*(1/3) = 9.667 and 29*(2/3) = 19.333. These are obviously 10.667 and 20.333 respectively. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@xxxxxx | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
Attachment:
signature.asc
Description: PGP signature