Last active
July 19, 2017 14:29
-
-
Save stepankuzmin/1e392ff9c675329c62e606f5ac8f394b to your computer and use it in GitHub Desktop.
Group by 15 minutes interval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with | |
| avg_by_hour as ( | |
| select | |
| id, | |
| date_trunc('hour', time) + (round(extract('minute' from time) / 15) * 15) * interval '1 minute' as interval, | |
| trunc(avg(free)) as free | |
| from velobike_2016_09_05 | |
| group by id, interval | |
| order by id, interval | |
| ) | |
| select | |
| id, | |
| interval, | |
| free | |
| from avg_by_hour |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.