Prepin
Log in

Viewing Duration of TV Shows

Approach / Explanation

The inquiry titled "TV Show Watch Time" requires you to analyze data that records users' viewing durations for television shows. Assuming we have a table named WatchTime containing fields such as UserId , ShowId , and TimeSpent , there are several possible interpretations based on what the interviewer may be seeking: They might be looking for the total viewing time for each TV show, which would involve aggregating the TimeSpent column. They could also be interested in the total viewing time for each individual user. Another possibility is that they want to know the average viewing time for each show or overall. They may also wish to identify the TV show with the highest viewing time. In the absence of specific guidance, it’s important to clarify with the interviewer which interpretation they intend. If the question is ambiguous, reach out to the interviewer to better understand their expectations.

Suggested Answer

If the interviewer is interested in the overall viewing time for each TV show, you can summarize TimeSpent by ShowId . Below is an example SQL query that accomplishes this: SELECT ShowId , SUM ( TimeSpent ) as TotalTime FROM WatchTime GROUP BY ShowId ; This SQL query organizes the watch time data by each TV show ( ShowId ) and calculates the total time spent by users on each show using the SUM function. The output will be a list of TV shows along with their total viewing times.

Alternative Answer

Alternatively, if the interviewer is curious about the average viewing time per user, you can obtain this information using the following SQL query: SELECT UserId , AVG ( TimeSpent ) as AverageWatchTime FROM WatchTime GROUP BY UserId ; This SQL query aggregates the watch time entries for each user ( UserId ) and computes the average ( AVG ) viewing duration across all TV shows they have watched. Keep in mind that when responding to SQL-related interview questions, it is essential to have a clear understanding of the data the interviewer wants you to fetch or modify. If anything is unclear, don’t hesitate to ask for further information, and ensure that your SQL syntax is correct and efficient for the tasks at hand.

Question Details

Difficulty & Category

Medium
sql

Product

For CandidatesFor RecruitersCompaniesBrowse JobsInterview QuestionsDeep ProfileSkill AssessmentOpportunity Matching
Prepin.ai

© 2026 Prepin LLC · Philadelphia, PA · All rights reserved.