Track the best-so-far value.
Section: Running metrics
Cumulative maximum
sql
sql
SELECT measured_at,
temperature,
MAX(temperature) OVER (
ORDER BY measured_at
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS max_so_far
FROM sensor_readings;Explanation
Cumulative max and min are compact ways to model records or thresholds.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Running metrics