rollup(tws TimeWeightSummary) RETURNS TimeWeightSummary
An aggregate to compute a combined
TimeWeightSummary from a series of
For more information about time-weighted average functions, see the hyperfunctions documentation.
|The input TimeWeightSummary from a previous |
|A TimeWeightSummary object that can be passed to other functions within the time weighting API|
WITH t as (SELECTdate_trunc('day', ts) as dt,time_weight('Linear', ts, val) AS tw -- get a time weight summaryFROM fooWHERE measure_id = 10GROUP BY date_trunc('day', ts)), q as (SELECT rollup(tw) AS full_tw -- do a second level of aggregation to get the full time weighted averageFROM t)SELECTdt,average(tw), -- extract the average from the time weight summaryaverage(tw) / (SELECT average(full_tw) FROM q LIMIT 1) as normalized -- get the normalized averageFROM t;
Found an issue on this page?Report an issue!