min_frequency() and max_frequency()

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

2. max_frequency (

4. agg SpaceSavingAggregate,

6. value AnyElement

8. ) RETURNS DOUBLE PRECISION

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

Name Type Description
agg SpaceSavingAggregate The frequency or top N aggregate created over the original dataset
value AnyElement The value to find the frequency of

Returns

Column Type Description
min_freq or max_freq DOUBLE PRECISION The minimum or maximum estimated frequency for the value
note

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:

2. SELECT toolkit_experimental.min_frequency(

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

6. 3

8. );

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

2. SELECT toolkit_experimental.max_frequency(

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

6. 'foo'

8. );