Sometimes you need to group rows by a time interval, say, one value per minute, or per hour. In this post, we will research how we can do that with vanilla PostgreSQL and with Django ORM.

When do you need it? Imagine you have a table that stores weather temperature measurements and takes a temperature snapshot every 10 seconds. In one hour it will collect 360 measurements. That’s would be a lot if your script runs for several months. Okay, now you want to render temperature measurements as data points on a line chart, and you also want your users…


Alex Oleshkevich

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store