Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- device
- , sum(measurement * num_seconds)
- , max(measurement)
- -- should return 270 as it was the num seconds the measurement was the max of 5
- , last_value(num_seconds) OVER (ORDER BY num_seconds)
- FROM (VALUES (1, 4, 6), (1, 4, 270), (1, 5,30), (1, 4, 2640), (1, 3, 654)) t(device, measurement, num_seconds)
- GROUP BY 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement