Skip to main content

Time Between Two Events

HardPremium

Given the schema shown below, write a function to identify the user who liked a post in the shortest time after logging in.

user_event +---------------+----------+ | user_id | int | | event | varchar | | timestamp | datetime | +---------------+----------+

Your function should output a result in the following format:

user_id | login | like | time_between --------+----------+----------+-------------- int | datetime | datetime | int
  • time_between should be rounded to the nearest minute