corr()

corr(
    summary StatsSummary2D
) RETURNS DOUBLE PRECISION

The correlation coefficient of the least squares fit line computed from a two-dimensional statistical aggregate.

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

Required arguments

NameTypeDescription
summaryStatsSummary2DThe input StatsSummary from a stats_agg call

Returns

NameTypeDescription
corrDOUBLE PRECISIONThe correlation coefficient of the least squares fit line.

Sample usage

SELECT
    id,
    time_bucket('15 min'::interval, ts) AS bucket,
    corr(stats_agg(y, x)) AS summary
FROM foo
GROUP BY id, time_bucket('15 min'::interval, ts)

Found an issue on this page?

Report an issue!

Related Content