I have a postgre SQL table, which has timestamp of various events in a chat. The table stores the following:
Timestamp | chat_id | event_type_id | user_id
What I am trying to accomplish, is to see the difference in time between event_type_id 1, and event_type_id 3, of each chat. Or alternatively, the avg of the time difference, pr user_id. So:
chat_id | time_difference(sec)
15 | 240
16 | 75
and so on, or:
user_id | avg_time
145 | 540
190 | 25
My SQL knowledge is quite basic, and I just cant seem to figure out how to do this correctly. Any SQL wizards out there that could help me out? I am doing this in Metabase if that makes any difference.