PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in data manipulation and analytics, focusing on session-level time calculations, user behavior metrics such as bounce rate, performance metric definition, and revenue attribution using SQL and Python.

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

Calculate Average Session Duration and Performance Metrics

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

user_sessions +---------+------------+------+---------------------+---------------------+ | user_id | session_id | app | start_time | end_time | +---------+------------+------+---------------------+---------------------+ | 123 | 1 | ins | 2023-07-04 10:00:00 | 2023-07-04 10:15:42 | | 123 | 2 | fb | 2023-07-04 10:20:00 | 2023-07-04 10:35:10 | | 456 | 3 | ins | 2023-07-04 11:00:00 | 2023-07-04 11:02:07 | | 789 | 4 | fb | 2023-07-04 12:00:00 | 2023-07-04 12:45:00 | | 123 | 5 | ins | 2023-07-05 09:00:00 | 2023-07-05 09:25:30 | +---------+------------+------+---------------------+---------------------+ ​ ads_stats +--------------+------------------+---------+---------+------------+ | advertiser_id | creation_source | country | spend | date | +--------------+------------------+---------+---------+------------+ | 101 | web | US | 1500.00 | 2023-06-15 | | 102 | api | CA | 200.00 | 2023-06-15 | | 103 | mobile | IN | 5000.00 | 2023-07-01 | | 104 | web | UK | 750.00 | 2022-07-01 | | 105 | api | US | 1200.00 | 2023-07-02 | +--------------+------------------+---------+---------+------------+ ##### Scenario SQL data-manipulation round covering user session analytics and advertiser revenue questions. ##### Question Using yesterday’s data, compute the average session duration (end_time ‑ start_time) grouped by app. Define a performance metric for each app, calculate it, and decide which app performs best. For every day and app, calculate the bounce rate where a user switches to another app then returns to the first. Ads tasks: i) For each creation_source, report daily revenue for the past month. ii) Find the top 10 least-active advertisers and list their countries. iii) For every creation_source, compare this-year vs. last-year ratio of advertisers spending > 1000. iv) Show how to prove a revenue increase from one source is due to decreases in others. ##### Hints Use date filtering, TIMESTAMPDIFF, window functions, self-joins for bounces, CTEs, and careful denominator selection for ratios.

Quick Answer: This question evaluates proficiency in data manipulation and analytics, focusing on session-level time calculations, user behavior metrics such as bounce rate, performance metric definition, and revenue attribution using SQL and Python.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,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.

Related Coding 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)