What is an efficient way to compute how much time someone has watched a movie in Python?
For this SQL version, calculate valid watched time from playback session offsets, including open sessions and offsets outside the movie duration. Exclude sessions without valid viewer or movie matches and sessions with no positive duration.
Output
- One row per viewer and movie with valid watch time.
- Columns:
viewer_id, viewer_name, movie_id, title, total_watched_seconds, and watch_percentage.
- Sort by
viewer_id, then movie_id, both ascending.