Interview Query

Meaningful Session Calculation

Have you seen this question before?

Let’s say that you’re given event data from users on a social networking site like Facebook.

A product manager is interested in understanding the average number of “sessions” that occur every day. However, the company has not technically defined what a “session” is yet.

The best the product manager can do is illustrate an example of a user browsing Facebook in the morning on their phone and then again during lunch as two distinct “sessions”. In which there must be a period of time where the user leaves Facebook to do another task before coming back again anew.

  1. Given a dataset of raw events, how would you come up with a measurement to define what a “session” is for the company?

  2. Given your definition, write a query to return the average number of sessions per day.

Next question: t Value via SQL
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query