List of user sessions in SQL
The frequently asked problem on interviews.
You have a log of some user activities represented as a table. Every activity record has at least users ID and activity date/time values.
The session is a sequence of activities having less than N minutes between two log records. When the elapsed …