Junior — Senior
Total viewing time of movies from smart_tv devices
livecode
Task condition
There are two tables: watch_events and devices. The watch_events table records user viewing events and contains the following fields: • user_id — user identifier; • movie_id — movie identifier; • duration_sec — number of seconds spent watching; • dev_id — device identifier from which the viewing was made. The devices table stores information about device types. Write an SQL query that, for each user, calculates the total viewing time (in seconds) for each movie, if the viewing was done from a device of type smart_tv.