Contribute to TimescaleDB Toolkit
We want and need your feedback! What are the frustrating parts of analyzing time-series data? What takes far more code than you feel it should? What runs slowly, or only runs quickly after many rewrites? We want to solve community-wide problems and incorporate as much feedback as possible.
- Join the [discussion][gh-discussions].
- Check out the [proposed features][gh-proposed].
- Explore the current [feature requests][gh-requests].
- Add your own [feature request][gh-newissue].
===== PAGE: https://docs.tigerdata.com/use-timescale/hyperfunctions/approx-count-distincts/ =====
Examples:
Example 1 (SQL):
SQL
SELECT device id,
sum(abs_delta) as volatility
FROM (
SELECT device_id,
abs(val - lag(val) OVER last_day) as abs_delta
FROM measurements
WHERE ts >= now()-'1 day'::interval) calc_delta
GROUP BY device_id;Example 2 (SQL):
SQL
SELECT device_id,
timevector(ts, val) -> sort() -> delta() -> abs() -> sum() as volatility
FROM measurements
WHERE ts >= now()-'1 day'::interval
GROUP BY device_id;