Currently, the table is like below.
datetime | number | content |
---|---|---|
2018-01-01 02:49:04 | 1 | spring |
2018-01-01 02:49:10 | 1 | spring |
2018-01-01 02:49:24 | 1 | spring |
2018-01-01 02:49:29 | 1 | summer |
2018-01-01 02:49:44 | 1 | spring |
2018-01-01 02:49:49 | 1 | spring |
2018-01-01 02:49:50 | 1 | winter |
2018-01-01 02:49:51 | 1 | spring |
If 'number' and 'content' columns have the same values, the time difference will have to be more than 10 seconds. ( * means it should be removed) So the table should be like below.
datetime | number | content |
---|---|---|
2018-01-01 02:49:04 | 1 | spring |
2018-01-01 02:49:24 | 1 | spring |
2018-01-01 02:49:29 | 1 | summer |
2018-01-01 02:49:44 | 1 | spring |
2018-01-01 02:49:50 | 1 | winter |
I refered to Delete Duplicate Data on PostgreSQL, but it's quite different from my case. I think the code would be like
DELETE FROM table a USING table b
WHERE
(DATETIME CALCULATION CODE)
AND a.number = b.number
AND a.content = b.content
Thank you for helping in advance.