min_frequency() and max_frequency()

Returns the minimum or maximum estimated frequencies of a value within a dataset.

max_frequency (
    agg SpaceSavingAggregate,
    value AnyElement

min_frequency and max_frequency are accessors that operate on a frequency aggregate or a top N aggregate. Create a frequency or top N aggregate over the original dataset, then call min_frequency and max_frequency on the aggregate.

Required arguments

aggSpaceSavingAggregateThe frequency or top N aggregate created over the original dataset
valueAnyElementThe value to find the frequency of


min_freq or max_freqDOUBLE PRECISIONThe minimum or maximum estimated frequency for the value


When you create a frequency aggregate, you set a threshold frequency. Values that appear with lower-than-threshold frequency are not tracked. Calling min_frequency or max_frequency with such values returns a frequency of 0.

Sample usage

Find the minimum frequency of the value 3 in a column named value within the table value_test:

SELECT toolkit_experimental.min_frequency(
    (SELECT toolkit_experimental.freq_agg(0.05, value) FROM value_test),

Find the maximum frequency of the value foo in a column named value within the table value_test:

SELECT toolkit_experimental.max_frequency(
    (SELECT toolkit_experimental.freq_agg(0.05, value) FROM value_test),

Found an issue on this page?

Report an issue!


Related Content