PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Data Manipulation (SQL/Python)/Meta

Compute time-spent percentage by app category

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in data manipulation and analytics, specifically SQL/Python skills for joining tables, aggregating session durations, handling missing app-category mappings, and computing percentage time spent over a recent seven-day window.

  • Medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Scientist

Compute time-spent percentage by app category

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

You work on Oculus app engagement analytics. ## Tables ### `user_activity` - `user_id` (BIGINT) - `date` (DATE) — day of activity (assume UTC) - `app_id` (INT) - `session_id` (VARCHAR) - `duration` (INT) — session duration in seconds ### `apps` - `app_id` (INT, PK) - `app_name` (VARCHAR) - `app_category` (VARCHAR) — expected to be one of a small set of categories, but may be NULL Relationship: `user_activity.app_id` → `apps.app_id`. ## Task For the **last 7 days** (inclusive) relative to `:as_of_date`, compute the **percentage of total time spent** in each `app_category`. ### Requirements - Join activity to `apps` to obtain `app_category`. - If an `app_id` in `user_activity` has no matching row in `apps`, treat the category as `NULL` (or label it as `'Unknown'`, but be consistent). - Percent should be computed as: \( \text{pct} = \frac{\text{category_duration}}{\text{total_duration}} \) ### Output One row per category (including `NULL`/Unknown if applicable) with: - `app_category` - `category_duration_seconds` - `pct_time_spent` (0–1 or 0–100, specify which in your query)

Quick Answer: This question evaluates proficiency in data manipulation and analytics, specifically SQL/Python skills for joining tables, aggregating session durations, handling missing app-category mappings, and computing percentage time spent over a recent seven-day window.

Related Interview Questions

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)
Meta logo
Meta
Aug 17, 2025, 12:00 AM
Data Scientist
Onsite
Data Manipulation (SQL/Python)
3
0

You work on Oculus app engagement analytics.

Tables

user_activity

  • user_id (BIGINT)
  • date (DATE) — day of activity (assume UTC)
  • app_id (INT)
  • session_id (VARCHAR)
  • duration (INT) — session duration in seconds

apps

  • app_id (INT, PK)
  • app_name (VARCHAR)
  • app_category (VARCHAR) — expected to be one of a small set of categories, but may be NULL

Relationship: user_activity.app_id → apps.app_id.

Task

For the last 7 days (inclusive) relative to :as_of_date, compute the percentage of total time spent in each app_category.

Requirements

  • Join activity to apps to obtain app_category .
  • If an app_id in user_activity has no matching row in apps , treat the category as NULL (or label it as 'Unknown' , but be consistent).
  • Percent should be computed as:
    \text{pct} = \frac{\text{category_duration}}{\text{total_duration}}

Output

One row per category (including NULL/Unknown if applicable) with:

  • app_category
  • category_duration_seconds
  • pct_time_spent (0–1 or 0–100, specify which in your query)

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Meta•More Data Scientist•Meta Data Scientist•Meta Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.