average()

average(
    tws TimeWeightSummary
) RETURNS DOUBLE PRECISION

A function to compute a time weighted average from a TimeWeightSummary.

Required arguments

NameTypeDescription
twsTimeWeightSummaryThe input TimeWeightSummary from a time_weight call

Returns

ColumnTypeDescription
averageDOUBLE PRECISIONThe time weighted average computed from the TimeWeightSummary

Sample usage

SELECT
    id,
    average(tws)
FROM (
    SELECT
        id,
        time_weight('LOCF', ts, val) AS tws
    FROM foo
    GROUP BY id
) t

Found an issue on this page?

Report an issue!