sorry for my bad formating, I've never used this platform.
I have a table with some timestamps and I want to select the ones which have more than 30 seconds from each other and are consecutive.
It goes like this:
table called 'nova' with only one column as 'tempo'.
Tempo |
---|
2021-06-04 13:48:46-03 |
2021-06-04 13:48:50-03 |
2021-06-04 13:54:06-03 |
2021-06-04 13:56:30-03 |
2021-06-04 13:56:31-03 |
2021-06-04 13:58:57-03 |
2021-06-04 13:58:59-03 |
2021-06-04 14:01:30-03 |
2021-06-04 14:01:35-03 |
2021-06-04 14:04:08-03 |
2021-06-04 14:06:45-03 |
I want to select the ones that are spaced as least 30 seconds apart. But whenever I state:
"select distinct t1.* from nova t1, nova t2 where t2.tempo-t1.tempo > '00:00:30';"
Postgres does not filter any entry as it operates all tuples with one another and there is always one combination where the difference is greater than 30 seconds.
I need to filter the consecutive entries, prioritizing the older entries, as follows:
Tempo |
---|
2021-06-04 13:48:46-03 |
2021-06-04 13:54:06-03 |
2021-06-04 13:56:30-03 |
2021-06-04 13:58:57-03 |
2021-06-04 14:01:30-03 |
2021-06-04 14:04:08-03 |
2021-06-04 14:06:45-03 |
thanks for your help!