-
Notifications
You must be signed in to change notification settings - Fork 53
CDB_QuantileBins
Sandro Santilli edited this page May 8, 2014
·
1 revision
Find the breaks for N categories in a numerical column based on the [Quantile bins]. Below, the quantile method is used to determine color based on the area of the polygons.
We can determine the 7 most optimal breaks in a column of numerical data as follows,
SELECT CDB_QuantileBins(array_agg(numeric_column), 7) FROM table_name
-- Results in an ordered array like, {80,2281,7162,17652,39730,91077,1638094}
-- Each break happens up to, and equal, to a number:
-- (bin1 is less than or equal to 80, bin2 is less than or equal to 2281, etc.)
CDB_QuantileBins(in_array, breaks)
- in_array numeric[]. A NUMERIC array of values.
- breaks int. The number of categories you want to create