Gini coefficient

The gini function calculates the Gini coefficient. The Gini coefficient is a measure of unequal distribution. A return value of 0 signifies signals that all values are equal. The return values approaches 1 if all values but one are zero.


The syntax of the function is

gini(x [,w])

x are the values for which the Gini coefficient shall be calculated. Null values are ignored.
If the number of values is zero, the function returns null.
w is the frequency with which the value x occurs. If no frequency is provided, the frequency is assumed to be 1.


SELECT gini(salary)
  FROM persons;