TOPN
Overview
Returns the top N most frequently occurring values as a JSON object in the format {"value": count, ...}, ordered by frequency in descending order.
Syntax
Parameters
<expr>: The column or expression to analyze. Note: only string-compatible types (STRING/VARCHAR) are supported; numeric types are not.<n>: INT type, the number of top values to return.
Examples
Related Documentation
- TOPN_ARRAY — returns only the top N value list without counts
- APPROX_TOP_K — approximate top K, suitable for large datasets
