Device Viewership Analysis
Netflix 👶 Easy SQL
Beginner Mode

Objective

Write a SQL query to calculate total viewership for laptop devices and mobile devices (tablet plus phone combined).

Table Schema:

  • viewership
Column Type Description
user_id INTEGER ID of the user
device_type VARCHAR Type of device used (laptop, tablet, or phone)
view_time DATETIME Date and time when the view occurred

Task Requirements:

  • Calculate total views from laptop devices
  • Calculate total views from mobile devices (tablet + phone combined)
  • Return aggregated counts for both device categories

Output columns: laptop_views, mobile_views

Examples

Example 1:

Input:

viewership
device_typeuser_idview_time
laptop1012024-01-15 10:00:00
tablet1022024-01-16 11:00:00
phone1032024-01-17 12:00:00
laptop1042024-01-18 13:00:00
tablet1052024-01-19 14:00:00

Output:
laptop_viewsmobile_views
23
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →