I have a database in Postgres SQL with information on users browsing online content. I would like to calculate the duration of browsing for each browsing episode (episode is one start and one stop action for the same Action_ID) and then to see it per user and per day. I can identify users by User_ID and by Action column to see when browsing started and ended.
I am therefore stuck with figuring out how to instead of having two rows per Action (with start and stop time) make one row per browsing Action with duration time only?
Date_time User_ID Device_ID Action Action_ID Channel_ID
22/07/2016 00:10 id2 pc stop 123qwe gn3
22/07/2016 00:10 id5 pc start 345ert tm6
22/07/2016 00:10 id1 mob stop 567rfg uy6
22/07/2016 00:12 id1 mob start 567rfg uy6
22/07/2016 00:13 d3 pc stop 987yhn io9
I've tried Calculate duration between momentjs timestamps in UTC and Calculate duration between timestamps in one column already and I've done some googling, but I didn't get any closer.
Thanks!