I have a table with messages and I need to find chats where were two or more messages in period of 10 seconds. table
id message_id time
1 1 13:09:00
1 2 13:09:01
1 3 13:09:50
2 1 15:18:00
2 2 15:20:00
3 1 15:00:00
3 2 15:10:00
3 3 15:10:10
So the result looks like
id
1
3
I can't come up with the idea how to group by a period or maybe it can be done other way?
select id
from t
group by id, ?
having count(message_id) > 1