num_vals()

num_vals(summary StatsSummary1D) RETURNS BIGINT
num_vals(summary StatsSummary2D) RETURNS BIGINT

Get the number of values contained in a statistical aggregate. This saves space when you need both a count and other statistical aggregates as part of a continuous aggregate. You do not need to specify a separate count aggregate.

For more information about statistical aggregate functions, see the hyperfunctions documentation.

Required arguments

NameTypeDescription
summaryStatsSummary1D/StatsSummary2DThe already constructed data structure from a previous stats_agg call

Returns

ColumnTypeDescription
num_valsBIGINTThe number of values in the stats agg

Sample usage

SELECT num_vals(stats_agg(data))
FROM generate_series(0, 100) data;
num_vals
-----------
       101

Found an issue on this page?

Report an issue!

Related Content