'In SQL, how to split timestamps into several intervals but with the first record of the day as the beginning of the first interval?

PostgreSQL 9.5

My dataset looks like this: Sample data


I want to split the records of the same day into a 1-minute interval, but with the beginning of each interval as the min value of the interval.

With this dataset, my ideal output would look like this: Output

For example, in 2014-05-27, the min value is 15:09:40, so the first one-minute interval would be 15:09:40 - 15:10:40, and there're three records. For the next interval, 15:11:01 - 15:12:01, there's one record.

Hope I have made myself clear. Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source