Average Screen Time by Device
What is the average daily screen time and app opens for each Apple device type?
- Aggregation
- Numeric functions
- Sorting
Challenge brief
Understand the request
Health & Wellness Team is building the Screen Time Insights dashboard and needs average usage metrics per device type.
Show average screen time and app opens per device type from device usage records.
Return
- device_type
- records (usage row count)
- avg_screen_time_mins (rounded 1)
- avg_app_opens (rounded 1)
Constraints
- Aggregate all daily device-usage records by device type
- Show the highest average screen time first and resolve ties by device type
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
device_usage
device_typeVARCHAR(50)screen_time_minutesINTEGERapp_opensINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
All data is in device_usage. Group by device_type and average the numeric columns. No JOIN needed.
Hint 2
GROUP BY device_type. COUNT(*) for record count. ROUND(AVG(screen_time_minutes), 1) and ROUND(AVG(app_opens), 1).
Hint 3
Build question 14 from its business grain: identify the driving rows, add only valid relationships, then apply the required filtering, aggregation, and deterministic ordering.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT device_type, COUNT(*) AS records, ROUND(AVG(screen_time_minutes), 1) AS avg_screen_time_mins, ROUND(AVG(app_opens), 1) AS avg_app_opens FROM device_usage GROUP BY device_type ORDER BY avg_screen_time_mins DESC, device_typeWhy this works
Single-table GROUP BY. AVG(app_opens) for iPhone rounds to 38.3 because there are 3 iPhone rows (45+32+38 = 115 / 3 = 38.33...). MacBook has the highest screen time but lowest app_opens per session — consistent with desktop work patterns.
Success check
4 device types — MacBook leads (450 min avg), Apple Watch lowest (60 min avg)
Expected result
Use this output to verify values, aliases, ordering, and row count.
| device_type | records | avg_screen_time_mins | avg_app_opens |
|---|---|---|---|
| MacBook | 2 | 450 | 15 |
| iPad | 2 | 280 | 25 |
| iPhone | 3 | 240 | 38.3 |
| Apple Watch | 1 | 60 | 15 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Microsoft
Independent Microsoft-style cloud, productivity, subscription, usage, support, and customer analytics SQL practice.
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Return to the complete interview preparation experience.