percentileCont()
returns the percentile of the given value over a group, with a percentile from 0.0 to 1.0. It uses a linear interpolation method, calculating a weighted average between two values if the desired percentile lies between them. For nearest values using a rounding method, see percentileDisc
.
Syntax:percentileCont(expression, percentile)
Returns: A Float.
Arguments
Name | Description |
expression | A numeric expression. |
percentile | A numeric value between 0.0 and 1.0 |
Example
MATCH (a:Person)
RETURN percentileCont(a.salary, 0.3)
The 30th percentile of the values in the property salary
is returned for the node Person. It is calculated with a weighted average. In this case, 0.3 is the median, or 30th percentile. For example, the result might be 40,143.5
Considerations
- All
null
values are excluded from the calculation. percentileCont(null, percentile)
returnsnull
.percentileCont(null, null)
returns an Error.
Example
MATCH (a:Student)
RETURN percentileCont(a.marks, 0.8)
The above query will return the 80th percentile of the values in the property marks
for the nodes with the label Student
. It will be calculated with a weighted average. The result for a given set of data is, for example-
percentileCont(a.marks, 0.8) |
78 |
Example
CREATE (a:Person {age:10}), (b:Person {age:15}), (c:Person {age:20}), (d:Person {age:25})
WITH a, b, c, d
MATCH (p:Person)
RETURN percentileCont(p.age, 0.75)
The above query will return the 75th percentile of the values in the property age
for all the nodes with the label Person
. It will be calculated with a weighted average. The result returned will be-
percentileCont(p.age, 0.75) |
20.5 |
Example
CREATE (a:Person {age:10}), (b:Person {age:null}), (c:Person {age:20}), (d:Person {age:null})
WITH a, b, c, d
MATCH (p:Person)
RETURN percentileCont(p.age, 0.5)
The above query will return the 50th percentile of the values in the property age
for all the nodes with the label Person
. It will be calculated with a weighted average. The result returned will be-
percentileCont(p.age, 0.5) |
10.0 |
Note– percentileCont()
will ignore all the null values from its calculation.
Example
RETURN percentileCont(null, 0.3)
Returns the following Result
percentileCont(null, 0.3) |
null |
Note– percentileCont(null, percentile)
will return null
.
Example
RETURN percentileCont(null, null)
Returns the following Result
percentileCont(null, null) |
ERROR Neo.ClientError.Statement.SyntaxError |
Note– percentileCont(null, null)
will return Error
.