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

Compare Survey Satisfaction for New and Established Users

Last updated: Jul 9, 2026

Quick Overview

Write PostgreSQL to compare survey satisfaction for new and established users across countries. The challenge emphasizes date-based cohort rules, invalid-event filtering, response and user counts, numeric averages, grouping, and output ordering.

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

Compare Survey Satisfaction for New and Established Users

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

The interview report preserved the survey tables and the request to compare response levels for new and old users, but it explicitly noted that the interviewer should clarify the cohort definition. The following is a self-contained practice reconstruction with that business rule supplied. You have two PostgreSQL tables: ```text survey ------ user_id BIGINT NOT NULL event_date DATE NOT NULL survey_event TEXT NOT NULL -- 'impression' or 'response' response INTEGER NULL -- 1 through 5 for a response; NULL for an impression users ----- user_id BIGINT PRIMARY KEY reg_date DATE NOT NULL country TEXT NOT NULL ``` Every `survey.user_id` has a matching `users` row. For this exercise: - A response from day 0 through day 29 after registration is from a `new` user. - A response on day 30 or later is from an `established` user. - Rows dated before `reg_date` are invalid and must be excluded. - Only rows with `survey_event = 'response'` and a non-null integer `response` from 1 through 5 are included. - Each qualifying row is one response event; a user may respond on multiple dates and each event counts. Write one PostgreSQL query that returns, for each `country` and user cohort: - `country` - `user_cohort`: exactly `new` or `established` - `response_events`: number of qualifying response events - `responding_users`: number of distinct users with at least one qualifying response in the cohort - `average_response`: the arithmetic mean of the qualifying 1-to-5 responses as a numeric value Do not emit groups with zero qualifying responses. Preserve numeric precision and order by `country` ascending, then `user_cohort` ascending.

Quick Answer: Write PostgreSQL to compare survey satisfaction for new and established users across countries. The challenge emphasizes date-based cohort rules, invalid-event filtering, response and user counts, numeric averages, grouping, and output ordering.

Related Interview Questions

  • Calculate Daily Survey Response Rates by Country - Meta (medium)
  • Find A Low-Quality Annotator From Label Data - Meta (hard)
  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
|Home/Data Manipulation (SQL/Python)/Meta

Compare Survey Satisfaction for New and Established Users

Meta logo
Meta
Jul 6, 2026, 12:00 AM
mediumData ScientistTechnical ScreenData Manipulation (SQL/Python)
0
0

The interview report preserved the survey tables and the request to compare response levels for new and old users, but it explicitly noted that the interviewer should clarify the cohort definition. The following is a self-contained practice reconstruction with that business rule supplied.

You have two PostgreSQL tables:

survey
------
user_id       BIGINT   NOT NULL
event_date    DATE     NOT NULL
survey_event  TEXT     NOT NULL  -- 'impression' or 'response'
response      INTEGER  NULL      -- 1 through 5 for a response; NULL for an impression

users
-----
user_id       BIGINT   PRIMARY KEY
reg_date      DATE     NOT NULL
country       TEXT     NOT NULL

Every survey.user_id has a matching users row. For this exercise:

  • A response from day 0 through day 29 after registration is from a new user.
  • A response on day 30 or later is from an established user.
  • Rows dated before reg_date are invalid and must be excluded.
  • Only rows with survey_event = 'response' and a non-null integer response from 1 through 5 are included.
  • Each qualifying row is one response event; a user may respond on multiple dates and each event counts.

Write one PostgreSQL query that returns, for each country and user cohort:

  • country
  • user_cohort : exactly new or established
  • response_events : number of qualifying response events
  • responding_users : number of distinct users with at least one qualifying response in the cohort
  • average_response : the arithmetic mean of the qualifying 1-to-5 responses as a numeric value

Do not emit groups with zero qualifying responses. Preserve numeric precision and order by country ascending, then user_cohort ascending.

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)

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
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
  • AI Coding 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.