PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Data Manipulation (SQL/Python)/Meta

Compute survey rates and bias-correct ratings

Last updated: Apr 8, 2026

Quick Overview

This question evaluates proficiency in data manipulation and analytics, specifically SQL window functions, joins, time-windowed de-duplication, aggregation of response and completion rates, and statistical reweighting to correct non-response bias.

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

Compute survey rates and bias-correct ratings

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Today is 2025-09-01. Use the schema and sample data below to answer A and B with SQL (standard SQL; you may use CTEs and window functions). Assume timestamps are UTC and exclude test users. Schema: - users(user_id INT, country STRING, is_test BOOLEAN) - survey_invites(invite_id INT, user_id INT, survey_id INT, sent_at TIMESTAMP) - survey_responses(response_id INT, user_id INT, survey_id INT, answered_at TIMESTAMP, is_complete BOOLEAN, rating INT) Sample tables: users user_id | country | is_test 1 | US | false 2 | IN | false 3 | US | false 4 | BR | true 5 | IN | false survey_invites invite_id | user_id | survey_id | sent_at 100 | 1 | 10 | 2025-08-26 10:00:00 101 | 2 | 10 | 2025-08-27 09:00:00 102 | 3 | 10 | 2025-08-28 12:00:00 103 | 1 | 11 | 2025-08-20 08:00:00 104 | 5 | 10 | 2025-08-29 14:00:00 105 | 4 | 10 | 2025-08-28 15:00:00 106 | 2 | 11 | 2025-08-30 11:00:00 107 | 2 | 10 | 2025-08-27 10:00:00 survey_responses response_id | user_id | survey_id | answered_at | is_complete | rating 200 | 1 | 10 | 2025-08-26 10:05:00 | true | 4 201 | 2 | 10 | 2025-08-30 09:20:00 | false | 3 202 | 2 | 10 | 2025-09-02 08:00:00 | true | 5 203 | 3 | 10 | 2025-08-28 13:00:00 | true | 2 204 | 5 | 10 | 2025-09-01 15:00:00 | true | 4 205 | 2 | 11 | 2025-08-30 12:00:00 | true | 5 A) For invites sent in the last 7 days (2025-08-25 through 2025-09-01 inclusive), compute per survey_id: response_rate and completion_rate. Rules: (i) Only non-test users; (ii) If a user receives multiple invites to the same survey, use the earliest invite in-window; (iii) Count a user as 'responded' if they have any response within 7 days after their earliest in-window invite and with answered_at <= 2025-09-01 23:59:59; (iv) 'Completed' requires is_complete = true under the same window. Return survey_id, invited_users, responded_users, completed_users, response_rate, completion_rate. B) For survey_id = 10 over the same 7-day invite window, compute a country-reweighted average rating that matches the invite country distribution to correct non-response bias. Use only complete responses within 7 days after the user's earliest in-window invite and with answered_at <= 2025-09-01 23:59:59. Let w_country = (invite_share_country) / (response_share_country). Output weighted_avg_rating rounded to 3 decimals and a breakdown table with country, invites, responses, invite_share, response_share, weight, and weighted contribution.

Quick Answer: This question evaluates proficiency in data manipulation and analytics, specifically SQL window functions, joins, time-windowed de-duplication, aggregation of response and completion rates, and statistical reweighting to correct non-response bias.

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
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
2
0

Today is 2025-09-01. Use the schema and sample data below to answer A and B with SQL (standard SQL; you may use CTEs and window functions). Assume timestamps are UTC and exclude test users. Schema:

  • users(user_id INT, country STRING, is_test BOOLEAN)
  • survey_invites(invite_id INT, user_id INT, survey_id INT, sent_at TIMESTAMP)
  • survey_responses(response_id INT, user_id INT, survey_id INT, answered_at TIMESTAMP, is_complete BOOLEAN, rating INT)

Sample tables: users user_id | country | is_test 1 | US | false 2 | IN | false 3 | US | false 4 | BR | true 5 | IN | false

survey_invites invite_id | user_id | survey_id | sent_at 100 | 1 | 10 | 2025-08-26 10:00:00 101 | 2 | 10 | 2025-08-27 09:00:00 102 | 3 | 10 | 2025-08-28 12:00:00 103 | 1 | 11 | 2025-08-20 08:00:00 104 | 5 | 10 | 2025-08-29 14:00:00 105 | 4 | 10 | 2025-08-28 15:00:00 106 | 2 | 11 | 2025-08-30 11:00:00 107 | 2 | 10 | 2025-08-27 10:00:00

survey_responses response_id | user_id | survey_id | answered_at | is_complete | rating 200 | 1 | 10 | 2025-08-26 10:05:00 | true | 4 201 | 2 | 10 | 2025-08-30 09:20:00 | false | 3 202 | 2 | 10 | 2025-09-02 08:00:00 | true | 5 203 | 3 | 10 | 2025-08-28 13:00:00 | true | 2 204 | 5 | 10 | 2025-09-01 15:00:00 | true | 4 205 | 2 | 11 | 2025-08-30 12:00:00 | true | 5

A) For invites sent in the last 7 days (2025-08-25 through 2025-09-01 inclusive), compute per survey_id: response_rate and completion_rate. Rules: (i) Only non-test users; (ii) If a user receives multiple invites to the same survey, use the earliest invite in-window; (iii) Count a user as 'responded' if they have any response within 7 days after their earliest in-window invite and with answered_at <= 2025-09-01 23:59:59; (iv) 'Completed' requires is_complete = true under the same window. Return survey_id, invited_users, responded_users, completed_users, response_rate, completion_rate.

B) For survey_id = 10 over the same 7-day invite window, compute a country-reweighted average rating that matches the invite country distribution to correct non-response bias. Use only complete responses within 7 days after the user's earliest in-window invite and with answered_at <= 2025-09-01 23:59:59. Let w_country = (invite_share_country) / (response_share_country). Output weighted_avg_rating rounded to 3 decimals and a breakdown table with country, invites, responses, invite_share, response_share, weight, and weighted contribution.

Comments (0)

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 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.